QPushButton dimensions change when Stylesheet is apllied - qt

When I apply a style sheet on QPushButton its dimensions change.
This is my style sheet declaration.
QPushButton {
background-color: rgb(175, 187, 199);
color: black;
border-width: 1px;
border-top: 1px solid white;
border-left: 1px solid white;
border-right: 1px solid grey;
border-bottom: 1px solid grey;
border-style: solid;
border-radius: 5;
padding: 3px;
padding-left: 5px;
padding-right: 5px;
font: 16px;
font-weight: bold;
}
Image - Before applying style sheet
Image - After applying style sheet
How to keep the original button size?

Based on comment below question: Try add qualifier:
MyDialog QPushButton {
background-color: rgb(175, 187, 199);
color: black;
border-width: 1px;
border-top: 1px solid white;
border-left: 1px solid white;
border-right: 1px solid grey;
border-bottom: 1px solid grey;
border-style: solid;
border-radius: 5;
padding: 3px;
padding-left: 5px;
padding-right: 5px;
font: 16px;
font-weight: bold;
}
This should be merged with default style sheet (not override the whole thing) and work only on buttons you need to alter.
See documentation.

Related

Remove border from QComboBox item

I'm trying to style a QtComboxBox and ListView but i'm not sure how to remove this annoying border when an item of the combobox is hovered. Here's what I have
QListView:
/*-----QListView-----*/
QListView
{
background-color: qlineargradient(spread:pad, x1:1, y1:0, x2:1, y2:1, stop:0 rgba(50, 61, 80, 255),stop:1 rgba(44, 49, 69, 255));
color: #fff;
font-size: 12px;
font-weight: bold;
border: 1px solid #191919;
border-radius: 10px;
show-decoration-selected: 0;
}
QListView::item
{
color: #green;
background-color: #454e5e;
padding: 5px;
border: 10px solid #191919;
border-radius: 10px;
padding-left : 10px;
height: 42px;
}
QListView::item:selected
{
color: #31cecb;
background-color: #454e5e;
border: 2px solid magenta;
border-radius: 10px;
}
QListView::item:!selected
{
color:white;
background-color: transparent;
border: none;
padding-left : 10px;
}
QListView::item:!selected:hover
{
color: #bbbcba;
background-color: #454e5e;
border: transparent;
padding-left : 10px;
border-radius: 10px;
}
QComboBox:
/*-----QComboBox-----*/
QComboBox
{
color: #fff;
font-size: 13px;
font-weight: bold;
border: 1px solid blue;
border-radius: 5px;
padding: 5px;
}
QComboBox::drop-down
{
width: 35px;
border: 1px solid blue;
border-radius: 5px;
padding: 5px;
}
Which gives me something like
What I want to do is to remove this grey rectangular selection around the item label, how do I go about this?
add border-style:none; where you don't want to see the border.
for example :
QComboBox#comboBoxName{
border-style:none;
}
I also Try this in your code and this is its result:
QComboBox::item {
width: 35px;
height:35px;
border-style:none;
}

How to style options in Appmaker MultiSelect Widget

I'm trying to use CSS to stylize the options within the MultiSelect widget, for example to make a border around each of the individual options.
Is there any way to do this through Appmaker? Thank you
app-MultiSelect-Item is what you are looking for to customize the options.
For example:
.app-MultiSelect-Item {
font-size: 12px;
line-height: 12px;
padding-bottom: 8px;
padding-top: 8px;
border: 1px black solid ;
border-top-right-radius: 20px;
border-top-left-radius: 20px;
border-bottom-left-radius: 20px;
border-bottom-right-radius: 20px;
background-color: #FF9800;
}
The CSS is different for checked/unchecked options
The following example has rounded borders on the sides. Red for unselected and green for selected (with a green background)
.app-MultiSelect-Input {
font-size: 11px;
font-family: Verdana;
}
.app-MultiSelect-Item {
border-radius: 10px;
border-right: 2px red solid;
border-left: 2px red solid;
line-height: 8px;
margin-top: 3px;
}
.app-MultiSelect-Item.selected {
border-radius: 10px;
border-right: 2px green solid;
border-left: 2px green solid;
background-color: lightgreen;
line-height: 8px;
margin-top: 3px;
}
source: [https://developers-dot-devsite-v2-prod.appspot.com/appmaker/scripting/api/widgets#MultiSelect][1]

QDockWidget - fonts getting caught off (decender part)

On QdockWidgets part of the text is being caught off, the "tail" part or decender in typography terminology. So for example Chapters and Settings, the "p" and the "g" are cut
/******** QDockWidget - this controls the top header for widgets ********/
QDockWidget {
titlebar-close-icon: url(:/Controls/ic_close2.png);
titlebar-normal-icon: url(:/Controls/ic_undock.png);
color: white;
font-size: 12pt;
}
QDockWidget::title {
text-align: left; /* align the text to the left */
background: #2e333b;
padding-left: 27px;
padding-top: 15px;
padding-bottom: 15px;
border-bottom: 1px solid black;
}
QDockWidget::close-button, QDockWidget::float-button {
border: 1px solid transparent;
border-radius: 2px;
background: transparent;
}
QDockWidget::close-button:hover, QDockWidget::float-button:hover {
border: 1px solid grey;
}
QDockWidget::close-button:pressed, QDockWidget::float-button:pressed {
padding: 1px -1px -1px 1px;
}
/*_______QDockWidget_______*/
The problem in border and padding here:
QDockWidget::title {
<...>
padding-bottom: 15px;
border-bottom: 1px solid black;
}
For example, you can reduce padding or remove border.

CSS file loads only half selectors

My asp.net website uses one CSS file with two groups of selectors ".Tab" and ".TabLower". On my development machine the CSS loads with all selectors and is applied correctly, when I deploy the website to production server (IIS 7) only the first selector ".Tab" is loaded if I inspect the page.
What is the cause of this issue?
CSS file
/* ############################################
Tab - default tab
############################################### */
/*Body*/
.Tab .ajax__tab_body
{
border: 5px solid #B6C9D4;
padding: 15px;
}
/*Tab Active*/
.Tab .ajax__tab_active .ajax__tab_tab
{
color: #000000;
padding: 7px;
background-color: #B6C9D4;
font-weight: bold;
}
.Tab .ajax__tab_active .ajax__tab_inner
{
background-color: #B6C9D4;
padding: 7px;
font-weight: bold;
border-top: 2px solid #ffffff;
border-left: 2px solid #ffffff;
border-right: 2px solid #ffffff;
border-bottom: 2px solid #B6C9D4;
}
/*Tab Inactive*/
.Tab .ajax__tab_tab
{
color: #666666;
background-color: #F2F2F2;
padding: 7px;
font-weight: bold;
}
.Tab .ajax__tab_inner
{
color: #666666;
background-color: #F2F2F2;
padding: 7px;
font-weight: bold;
border-top: 2px solid #ffffff;
border-left: 2px solid #ffffff;
border-right: 2px solid #ffffff;
border-bottom: 2px solid #ffffff;
}
/* ############################################
TabLower
############################################### */
/*Body*/
.TabLower .ajax__tab_body
{
border: 5px solid #B6C9D4;
padding: 15px;
}
/*Tab Active*/
.TabLower .ajax__tab_active .ajax__tab_tab
{
color: #000000;
padding: 4px;
background-color: #B6C9D4;
font-weight: bold;
}
.TabLower .ajax__tab_active .ajax__tab_inner
{
background-color: #B6C9D4;
padding: 4px;
font-weight: bold;
border-top: 2px solid #ffffff;
border-left: 2px solid #ffffff;
border-right: 2px solid #ffffff;
border-bottom: 2px solid #B6C9D4;
}
/*Tab Inactive*/
.TabLower .ajax__tab_tab
{
color: #666666;
background-color: #F2F2F2;
padding: 4px;
font-weight: bold;
}
.TabLower .ajax__tab_inner
{
color: #666666;
background-color: #F2F2F2;
padding: 4px;
font-weight: bold;
border-top: 2px solid #ffffff;
border-left: 2px solid #ffffff;
border-right: 2px solid #ffffff;
border-bottom: 2px solid #ffffff;
}

Pagination buttons not showing disabled css

For some reason when it knows the button is supposed to be disabled it shows the css for the .paginate_button and then crosses out the css for the .paginate_button_disabled. Does anyone know why?
.paginate_button_disabled {
border: 1px solid #F3F3F3;
color: #CCCCCC;
margin-right: 2px;
padding: 2px 5px;
border: 0;
}
.paginate_button:hover {
border:1px solid #52bfea;
color: #fff;
background-color: #52bfea;
}
.paginate_active {
padding: 2px 5px 2px 5px;
margin-right: 2px;
border: 1px solid #52bfea;
font-weight: bold;
background-color: #52bfea;
color: #FFF;
}
.paginate_button {
padding: 2px 5px 2px 5px;
margin-right: 2px;
color: #52BFEA;
border: 1px solid #52BFEA;
}
Assuming you are adding .paginate_button_disabled to the element without removing .paginate_button, you will need to reorder your css.
The .paginate_button rule should come first:
.paginate_button {
padding: 2px 5px 2px 5px;
margin-right: 2px;
color: #52BFEA;
border: 1px solid #52BFEA;
}
.paginate_button_disabled {
border: 1px solid #F3F3F3;
color: #CCCCCC;
margin-right: 2px;
padding: 2px 5px;
border: 0;
}
.paginate_button:hover {
border:1px solid #52bfea;
color: #fff;
background-color: #52bfea;
}
.paginate_active {
padding: 2px 5px 2px 5px;
margin-right: 2px;
border: 1px solid #52bfea;
font-weight: bold;
background-color: #52bfea;
color: #FFF;
}
The way CSS works, is it cascades down the document. So if they both have the same specificity the CSS rule lower down will win.
If you are just adding the .paginate_button_disabled class to the element, without removing the .paginate_button class, then the latter would overwrite the disabled rules as it is defined later in the CSS document - they are literally cascading styles.
The best solution is to hide any unnecessary button.
use the following :
.paginate_button_disabled {
display: none;
}
in this case previous, next, first and last buttons will be shown only when they are needed.

Resources