QFrame's stylesheet affecting QLabel - qt

I am using QFrame just to have colored border, since I couldn't find
the a way to change color of the QDialog. So because of tampering with
QFrame's border, it is also affecting the QLabel's look, is there any
way to avoid this?
Edit:
Here is the Stylesheet which I am using, where QLabels' doesn't have any effect. It's taking QFrames'
QWidget {
background-color: black;
}
QLabel {
color:white;
border: solid 2px black;
font: bold 19px Sans Serif;
}
QFrame {
border: solid 2px white;
border-radius: 4px;
}

Instead of using a type selector which matches all the instances of that class and its subclasses, use a class selector.
So in your stylesheet, instead of using QFrame{...}, use .QFrame{border: 1px solid red;}. Note the . before the class name.
See more about selector types here.

Related

QDockWidget Tab Stylessheet

How I can change these tabs at the bottom from the design? I just can't find the prefix needed to color the tabs to match my design.
Assuming that those tabs are part of a QTabWidget, you can either modify the stylesheet in Designer with something like this:
QTabBar:tab { color: white; border: 2px solid #00FFFF; background-color: gray;}
Or you can do it via code like this:
ui->tabWidget->setStyleSheet(QStringLiteral ("QTabBar:tab { color: white; border: 2px solid #00FFFF; background-color: gray;}"));
You would obviously need to change the colors in the example to the colors you would want. You should also read Customizing QTabWidget for more examples and the full reference of what is possible.

Adding css border style

Can someone help me, please?. I want to add a border style in the link:hover, to a component of primefaces.
I add like this:
.ui-contextmenu .ui-menuitem-link:hover{
font-weight: bold;
border-style: solid;
border-width: thin;
}
In a file calling pfcrud.css.
The problem is that, the border style is not working/showing.
Thanks!.
Use the shorthand method: border: thin solid black;
CSS
.ui-contextmenu .ui-menuitem-link:hover{
font-weight: bold;
border: thin solid black;
}
Note that this will change the box-model of the element in question, so when you hover over it this border will effectively increase the element size. You may need to consider accommodating for that change by declaring a rule for the element's natural/default state as well, usually a border with the same width, but transparent works in most cases.
May be this you want to try :
.ui-contextmenu .ui-menuitem-link:hover{
font-weight: bold;
border: 1px solid #a32ddf
}
Updated fiddle of bucurvad: https://jsfiddle.net/upq3045g/3/
More info about border at : http://www.w3schools.com/css/css_border.asp
Have you tried using
.ui-contextmenu .ui-menuitem-link:hover {
border-style: solid black 2px;
}
Is this example ok?
https://jsfiddle.net/upq3045g/2/

How do I create a white background for my text area (change it from a different colour)?

My website - http://www.automated-stores.com has the strange feature of a blue-ish background for text areas, seen more specifically here: http://www.automated-stores.com/vending-machines-business-electronics-cosmetics-perfume
I didn't code the website, but I suppose that to change this it would have to be in the stylesheet.css, does anyone know what code to enter/change?
I thought it would be this:
input,textarea,select {
padding: 1px;
border: solid 1px #000000;
font-size: 10pt;
color:#000000;
background-color:#ffffff;
}
(the colours were different before) but I have changed it several times with no effect.
I looked through your source code and you need to find your style.css under your root and change this:
input,textarea,select {
padding: 1px;
border: solid 1px #5c8593;
font-size: 10pt;
color:#42484d;
background-color:#224f5f;
}
to this:
background-color:#ffffff;
Remember this will affect everything with the class of input, textarea, select. I used the chrome inspect and firebug lite tool to verify this and it worked. If you only want to effect text areas bg color do this:
input,select {
padding: 1px;
border: solid 1px #5c8593;
font-size: 10pt;
color:#42484d;
background-color:#224f5f;
}
textarea {
padding: 1px;
border: solid 1px #5c8593;
font-size: 10pt;
color:#42484d;
background-color:#ffffff;
}
The code in the question does it, provided that you insert it e.g. in a style element after the tag <link rel="stylesheet" href="style.css" type="text/css" />. The external style sheet sets the background color etc. in a simple manner, which can easily be overridden, provided that you place your code after that link tag.
If this does not appear to work, check, in a browser, the HTML source code of the page. It is possible that the server software does some modifications to your code or that your browser has got an old version of the page (Ctrl+F5 should help then).
your <textarea> have attribute <... class="textarea"... You could add this to your stylesheet
.textarea {
background-color: #FFFFFF;
}
The specific rules changing the color of the textarea on the page you gave (the second link) is in style.css line 44:
input, textarea, select {
background-color: #224F5F; // This is the blue background
border: 1px solid #5C8593;
color: #42484D;
font-size: 10pt;
padding: 1px;
}
If it is just textareas that you want to style but dont want to touch the formatting you can do one of two things:
Option 1
Keep CSS as it is and add this underneath:
textarea {
background-color:#FFFFFF !important;
}
I dont like doing this as it makes the CSS to rigid and lots of !important declarations makes managing the style very difficult.
Option 2
Change line 44 styling to:
input, textarea, select {
border: 1px solid #5C8593;
color: #42484D;
font-size: 10pt;
padding: 1px;
}
textarea {
background-color: #FFFFFF;
}
input, select {
background-color: #224F5F;
}
I'd recommend simply targeting the textareas and changing their background colour and giving them a border.
textarea {
background-color:#FFF;
border:1px solid #224f5f;
color:#000;
}

customizing tab control in stylesheet in qt

I would like to do changes only for a specific tab. How can I do it?
I tried both:
QTabBar::tab#tbGeneral{... }
QTabWidget::tab-bar#tbGeneral{... }
None worked.
You have probably looked into Customizing QTabWidget and QTabBar.
To style individual tabs based on their state (:only-one, :first, :last, :middle, :previous-selected, :next-selected, :selected) you can use stylesheet-code similar to this:
QTabBar::tab {
border: 1px solid #C4C4C3;
border-bottom-color: #C2C7CB;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
padding: 1px 3px;
margin-left: 1px;
margin-bottom: 4px;
}
QTabBar::tab:selected {
background-color: #f14040;
border-bottom-style: none;
}
As the individual tabs are not widgets (or objects), they have no object name or other properties that could identify them to a stylsheet. You can only use the pseudo-classes to style tabs with a stylesheet.
You'll probably have to use (C++) code to change the style of a tab depending on the label. The recommended way for customizing styles in Qt is through the class QStyle. You can either subclass QStyle or use QProxyStyle to change the looks of specific widgets. The other alternative (probably not recommended by Qt) is though subclassing QTabBar and reimplementing the function QWidget::paintEvent( QPaintEvent *event).

How to use CSS to square the corner on a submit button

How do I square the corners of a submit button? Can it be done with CSS? I just noticed that Stackoverflow buttons are pretty much the same thing (don't close it for mentioning SO, just want to illustrate what I mean).
Use the following field and command in your css:
border-radius: 0;
Just add CSS to it, and the default look will dissappear.
input.button, input.submit {
border: 1px outset blue;
background-color: lightBlue;
}
edit: changed the selector to use class name instead, as suggested in comments.
You could use the HTML element instead of input type. It's quite easy to style that one.
If you specify the height and width in the css, you'll make the corners square, and retain the certain level of automatic fancy-ness that normal buttons have... and that way, you wont have to build your own.
input.button, input.submit {
height: 30px;
width: 20px;
}
I seem to remember this only working if the height is large enough, but it might work any which way.
Use border: 1px solid for the element.
<a class="test">click me</a>
<style>
.test
{
cursor: pointer;
background-color:#E0EAF1;
border-bottom:1px solid #3E6D8E;
border-right:1px solid #7F9FB6;
color:#3E6D8E;
font-size:90%;
line-height:2.2;
margin:2px 2px 2px 0;
padding:3px 4px;
text-decoration:none;
white-space:nowrap;
}
</style>
This is how a stackoverflow button is made.

Resources