Qt set widget background color. Obviously, if this is possible.

jpg' ); But most probably you wont see the image because you set it to the main window directly. Is is possible to change the background color at run time, i. setObjectName (“title”) Aug 24, 2010 · 11. To apply the style sheet only to the container, and not to its children, the container widget can be named and the style Nov 29, 2017 · setStyleSheet("background-color:gray;"); setAutoFillBackground( true ); All the widgets take the background color from main window. So if you do not want to replace existing stylesheet which can contain borders padding and margin and you want to change background only, use QPalette: QPalette palette = _ui->lnSearch->palette(); palette. Apr 16, 2015 · Don't think it's possible to style a window titlebar in a platform independent way with Qt. Here you choose QWidget as a Base class in Qt Creator: Jul 4, 2013 · import sys from PyQt4 import QtGui, QtCore class MainWin(QtGui. setTabBar to replace the default tab-bar. The problem is that I can't set background of overlay widget to be transparent. 105 8. setBackground(QtGui. setColor(ui->label->backgroundRole(), Qt::darkGreen); ui->label->setPalette(palette); Jan 28, 2019 · First (change only one widget): Rightclick of the Widget, click "Change Stylesheet" and the Stylesheet window open, when you cange something inside the window you the widget will changed too. I already know how to change all the headers together, using: ui->tableWidget->setStyleSheet("QHeaderView::section {background-color:red}"); But I need to change the items individually. while switching between widgets? I tried the same above commands , but It show the one set in ctor. h" #include <QHeaderView> #include <QTableWidgetItem> #include <QLabel> #include <QPushButton> Unlike background-image and border-image, one may specify a SVG in the image property, in which case the image is scaled automatically according to the widget size. Should I have to overload its paintEvent to Do It? thanks. 1. backgroundRole(), QtCore. setOpacity(1. Qt Style Sheets (QSS) are always propagated to children, meaning that any tree view will use those selection colors, including widgets that are being designed. table. Jun 7, 2015 · You could use stylesheets in order to change the color of the checkbox or any othe widget as you wish. Jul 12, 2018 · Unfortunally not all theme/styles are implemented in the same way, and both the Windows and Fusion styles need to set the color for the palette. QDialog. maybe you set this style sheet in wrong widget. I need a function to change the row Feb 5, 2010 · I want to change the text color of the items in { color:#00ff00; background-color:transparent; } Set it by Set text color of QTableWidgetItem (Qt) 1. A general background color. I want to change the color of TICK in the QCheckBox from black into dark blue, I tried QSS, but it doesn't work: QCheckBox { background-color:blue; color:blue; } Using QSS only change the background color, but I want to change the color of the tick. YourClass[customPropertyName="1"] { background-color: transparent; } . Well, Thanks. Jan 9, 2020 · I would like to create a widget with a background color, but I do not want to change the color of the buttons & comboboxes. I will check there. Supports the box model. QAbstractScrollArea. Jun 8, 2012 · The view draws the background based on the Qt::BackgroundRole role of the cell which is the QBrush value returned by QAbstractItemModel::data(index, role) for that role. 7. WA_TranslucentBackground or indeed like you say should have a transparent background Nov 21, 2017 · It seems to me that the default white background color of QTextEdit (PyQy4) can't be changed by means that are otherwise working for other Qt widgets. same way you handle the item cell painting Apr 18, 2018 · You need to call setAutoFillBackground(True) on the widget. I want the toolbar to stay grey, but the central widget should have a white background. It is usually white or another light color. item(1,0). The steps to render a rule are as follows: Set clip for entire rendering operation (border-radius) Draw the background (background-image) Draw the border (border-image, border) Como Cambiar el Color de fondo de un QWidget. I have tried the following: w. The background color is set as described on the question: item->setBackgroundColor(qcolor); // change color slot inside QListWidget class In order to define rules how the widget is painted, I re-define the delegate: class Delegate : public QStyledItemDelegate {}; Then I re-define Delegate's method paint(). Apr 26, 2016 · How can I make my buttons - of a background color and text color that I don't know, but the button does - have that "disabled look" ? (Note - the color update works on disabled items too - that is not really complicated though - whatever style sheet I apply on setting widget disabled can be applied in the colorUpdate function). Qt's built-in widgets use it to perform nearly all of their Sep 6, 2021 · QColorDialog is the pop up type widget in the PyQt5 used for selecting and creating colors. How to Style. I need to set the length of the left part (cyan) as the percentage of the widget length, e. QPalette::AlternateBase: 16 With that solution, we are setting the background on an already existing item in the table to a light grey on the item at row 0, column 1: self. For the widget containing the button, radio button and checkbox I set the styleSheet property to background-color: #FFFFFF . And if I preview the widget from inside Qt Creator, the image appears, but doesn't after building and running. kamalakshantv. e. setColor(self. Mar 21, 2015 · to make it fade in fadeout u need to to use QGraphicsOpacityEffect along with setAutoFillBackground(True) a small example: write inside the widget which is called inside the mainwindow. The only way to get it to work is: QWidget { background-color: white} but that changes background of all controls on the page to white as well. May 6, 2020 · But if I add a background color with. Jul 21, 2017 at 10:05. To make the changes of colors you can use stylesheets, in Qt Designer you must follow the following steps: Right click on the item you want to change and select: change stylesheet. Qt. backgroundRole(), QColor(0,0,0)) w. setAutoFillBackground(True) p = w. For example, you might use this in a drawing program to allow the user to set the brush color. Create a QPalette and set its QBrush with your QPixmap and its ColorRole to QPalette::Window. The catch is that the widget has to be polished. QPalette::WindowText: 0: A general foreground color. Actually the row to which I am trying to set a background color also has some color set to it in table widget stylesheet. Jan 19, 2017 · 0. 2) for each of the QTreeWidgetItem I want to set the background color, to do this I have done QTreeWidgetItem::setBackground(0,QColor(Qt::green)); , but problem is, it is changing the color only if the item gets selected. Hence I tried with palettes: QPalette palette = ui->label->palette(); palette. I want to maintain my existing stylesheet for the QtabWidget and only add the blue background in the area marked by the red arrows. That background area remains "white" (or Jun 9, 2018 · now I need to programmatically change the background color of a label when something happens. "QTabBar::tab:disabled {". For the font and the color of the title only Chris code works. Jul 31, 2018 · I solved this problem with morph into QWidget, right click on verticalLayoutName and morph it. I am applying the below style using Qt Designer on the root widget. You can either use a QFrame instead or setting the WA_StyledBackground attribute of the QWidget to True as said here : PySide: QWidget does not draw background color. Code: void myWin::myFunction(int count, QVector<QColor> sampleInfoColor, QVector<QStringList> info) { sampleTable->setRowCount(count + 1); QFont nameFont; nameFont. Indicates the widget should be drawn using a styled background. The static getColor () function shows the dialog, and allows the user to specify a color. In addition, Qt Designer provides style sheet integration, making it easy to view the effects of a style sheet in different widget styles. You can also use stylesheets to change color if you wish. Aug 15, 2015 · 29. The widget itself has a transparent background because of the attribute QtCore. It depends. I'm trying to display a little square of solid color. you are welcome, it's a good practice. Box { border: 1px solid grey; } The latter is easier, in my opinion, as it doesn't require the use of id names. Then set Attach Widget :hover color. . If you're using a widget-style which doesn't draw the tabs using pixmaps (see this Qt FAQ for details), you can create a subclass of QTabBar and re-colour the tabs in a reimplemented paintEvent, and then use QTabWidget. This delegate will check the foreground color role of the item. WA_TranslucentBackground and doesn't need the style sheet itself but child widgets contained in the widget however that have autoFillBackground()==True by default should have it unset or should have set QtCore. Unlike palette fiddling, style sheets offer guarantees: If you set the background color of a QPushButton to be red, you can be assured that the button will have a red background in all styles, on all platforms. Note that some widgets derived from QWidget will automatically draw backgrounds. By default, a QWidget does not fill its background. Nun bleibt noch eine weitere Möglichkeit, nämlich die, Style Sheets zu verwenden: widget->setStyleSheet("background-color:black;"); To be more precise I could have used: QWidget#idName { border: 1px solid grey; } or. So maybe transparent color doesn't work but if I can create a proper mask from my bg color, then that's better. Thank you, Sep 14, 2020 · But I want to have all background with the color cyan. The layout contains two QLabels. Forcing them to be destroyed by class destructor enforces particular order. For more information, see the documentation for the setAutoFillBackground property. HI, I am trying, with no luck, to change teh background color of a widget. qt. Usando la Paleta. May 27, 2019 · I've been trying to choose the background colors of the selected cells in my QTableWidget. I prefer to do it this way instead of writing tedious line sof code :) – marouane18. self. Its constructor needs to be changed to ask Qt to draw the background using the style information: MyCustomWidget(QWidget *parent) : QWidget(parent) {. one QIcon in the left; two QLabel in the middle, vertically; one QLabel in the right; I want to change the text color and background color of all QLabels on hover. Widgets that set their background to be translucent will be transparent for all unpainted pixels, and the background will shine through pixels painted with an opacity of less than 100%. And something strange is happening, if I add an ; affter the first } then the color is working and the border is not set, if I remove the ; then the color is not working and the border is set. When I added QCheckBox::indicator{ background-color : cyan; } the button became all cyan (like on the first image on the state unchecked) on checked and This widget should have the same grey background color as the main window (picture A). I want to set a border for this whole widget. Only QLine edit uses the Base color. 0. (Or maybe tabWidget->findChild<QTabBar *>() would work for you to avoid subclassing. good luck I want to set background color of QStackedWidget to white but the stylesheet isn't taking effect. If you want to use an arbitrary background color, you need to modify the widget's palette instead: By default in Qt4, a QWidget will draw nothing for its own background, and only its children will be drawn. setColor(QPalette::Base, Qt::green); _ui->lnSearch->setPalette(palette); If you are creating your own custom widget that inherits from QWidget, you need to override the paintEvent () for your custom widget to make the stylesheet work. In Qt Designer everything renders as desired: But in Pyside the widget does not draw the background color - but the items on it inherit the color correctly: Here's the ui-XML: <class>MainWindow</class>. op=QGraphicsOpacityEffect(self) op. h, It works fine and shows up after build. setBold(true); Feb 10, 2014 · Once you've defined the QSS of interest as a string, you then set the QSS on the widget in question using the setStyleSheet method. backgroundRole(), Qt. All derivatives of QAbstractScrollArea, including QTextEdit, and QAbstractItemView (all item view classes), support scrollable backgrounds using background-attachment. try this: ui->listWidget->setStyleSheet("QListView::item:selected{background-color: rgb(255,0,0);}"); if not work again maybe your IDE is have a problem. El primer ejemplo ilustra como cambiar el color de fondo por medio de QPalette. First, we would use the following application-wide style sheet: *[mandatoryField="true"] { background-color: yellow } This means that every widget whose mandatoryField Qt property is set to true would have a yellow background. However, when I add background-color: to the styleSheet tab on Qt creator, the result is that all the pages of the stacked widget get that background color. Mar 31, 2020 · In Qt Designer this looks perfect --- the whole widget, its background, all its descendants are colored. Qt Widgets. List of Stylable Widgets. I'm using Qt 4. jpg ); background: rgb ( 67, 67, 67 ); #MainWindow. In short i want to add a background color under the tabs. QWidget {background-image: url (. The other thing comes from How to Change the Background Color of QWidget. 00) #0 to 1 will cause the fade effect to kick in. Note: If you subclass a custom widget from QWidget, then in order to use the StyleSheets you need to provide a paintEvent to the custom widget : Jan 28, 2020 · @qt-1234 said in Change Highlight item's color if a QListWidgetItem: @Fuel-0 it does not work even if i use QListWidget. Nov 26, 2009 · Answering myself, here is what I ended up doing : a delegate. Set your MainWindow palette to the palette you just created. palette() palette. Calling centralWidget->setStyleSheet("background-color: white;") at first seemed to do the job, but using it with a Designer-generated widget (a Q_OBJECT) doesn't Mar 9, 2016 · The cell background color seems to work with the above style, but now the border isn't showing anymore. How to modify the above to have it only configured as a background image to the root widget. Dark role, which makes the whole solution very platform and style dependent, as an user could have his/her own styles installed. I've created a QGraphicsView widget myGraphicsView and call: ui->myGraphicsView->setBackgroundBrush(QBrush(Qt::red, Qt::SolidPattern)); But it stays white. Mar 13, 2018 · this->setStyleSheet("background-color: grey;"); I have tried multiple ways to set the color of the QFrame, however it takes on the default grey color that I have set. Qt 6. You can subclass the QSqlQueryModel to redefine data() to return your calculated color, or if you have Qt > 4. setAutoFillBackground(True) palette = widget. If you want something for "mouse over" you may have to use "hover Style Sheet. The edit boxes’ background color has changed to grey Oct 28, 2018 · Solution. The following stylesheet will set a gray 3px border to the checkbox rectangle. You can do that with stylesheet QTabBar::tab { background: transparent; } Note that this is styling QTabBar, not QTabWidget. The widget is initialized with the current month and year, but QCalendarWidget provides several public slots to change the year and month that is shown. Also tried applying the stylesheet directly to the page, but that didn't work either. Oct 6, 2018 · 1)I have QTreeWidget and there are many QTreeWidgetItem attached to it. Mar 5, 2015 · I wanted to know how I could change the background color of the QtabWidget. setColor(w. #include "mainwindow. By default, today's date is selected, and the user can select a date using both mouse and keyboard. show(), but it's parented to another app written in C++ but also uses qt. Oct 21, 2010 · K. If this foreground color is not the default WindowText color of the palette, that means a specific color is set and this specific color is used for the highlighted text color. Docs: Qt 5 Style Sheet, Qt 6 Style Sheet. Yes it's possible The ::title subcontrol can be used to customize the title bar. If you want to override that, you specifically have to tell the widget to draw its background via one of its properties. 46. I'm using style sheet: Sep 11, 2014 · ui->tableWidget_2->setStyleSheet("QTableWidget::item{background-color: red;}"); In header: bool eventFilter(QObject *obj, QEvent *event); QString string; As you can see, with stylesheet you can customize your cells, so you can do much more than changing background color, of course, if you want this. Aug 29, 2018 · And one of examples given was link to this article: wiki. This function can also be used to let users Sep 30, 2014 · . Pixels that are not painted at all will also not receive any Oct 13, 2015 · I know how to set the Horizontal Headers background color, but how can i set the Headers Background Color for a specified Row? In this example, say i want to have the Header Row with the Label "3" to be red? The above screenshots code: Oct 12, 2020 · Hi guys. @Eslam, Chris is right: I tried both. setPalette(palette) # add layout and child widgets. Also tablewidget items also have a background color. To achieve the trick, I set "disabled = true" to get the orange color on a "new message received" tab. setColor(widget. QColor(125,125,125)) It's working, but set background for the row with iterating needs more time if you have more then one table. Make the window widget transparent using attribute Qt::WA_TranslucentBackground, which gives you something like in your picture: Make the tab header transparent. 8. I use a custom QTableWidgetItem that has the following data method: QVariant MyItem::data(int role) const Nov 7, 2012 · The best and recommended way is to use Qt Style Sheet. There I define how to draw each row of Jun 16, 2014 · How can I set the background color for a part of the background like in the following image: Of course, without border frames, I want to set only the cyan color. Note. I accomplished this by editing the Style Sheet in Qt Designer with: background-colour: rgb(240, 240, 240); But now I have two new problems I can’t solve: The buttons (--> Send) are not rounded anymore. edited Jan 20, 2017 at 20:00. And it's central widget is covering over it, since you also set a background color for all QWidgets. What I already tried: setPalette(Qt::transparent); setAttribute( Qt::WA_TranslucentBackground, true ); setAttribute( Qt::WA Nov 24, 2023 · selection-color: white; } Then run Designer as follows: > designer -stylesheet customstyle. The first style defines a background-color for all QLabel objects in your application, whereas the later one styles the title object only. Second (change all selected widget): Use the property window, mark all widget you want to change, click of the of the styleSheetrow. Feb 19, 2011 · Qt::red : Qt::blue); ui->tableWidget->setItem(row, column, newItem); } } if you would want to make it simpler, consider using QTableView widget instead, implement your model (I guess the easiest way is to subclass QStandardItemModel) and hold row colors there. Feb 28, 2014 · You can override this in stylesheet, but it's good to keep all color management in one place, so an easy fix would be to force the ui to use palette for selection: @ ui->listWidget->setStyleSheet ("QListView::item:selected { background: palette (Highlight) }"); @ Then you can control the actual color via palette with all the other colors. I have a QWidget with QHBoxLayout on it. So @SPlatten if you want/need to use the code you have been shown as-is, looks like you will need to subclass QTabWidget so as to gain access to QTabWidget::tabBar(). black) self. g 30%. But I already know that, and in fact what u said was just what I did. ekhumoro. The static functions provide modal color dialogs. It's not really supported and results may vary. here is my code. have a look at this example,here they have done custom selection color. May 11, 2010 · Hey, you set the delegate method for the table widget. Using setStyleSheet I can set the colour of the individual tab panels, but this doesn't The color dialog's function is to allow users to choose colors. red) widget. setAutoFillBackground(True) p = self. Color dialog is a huge widget that consists of lots of child widgets so it become tough to set stylesheet to the color dialog as it is a complex widget, below is how the background color to the QColorDialog widget’s QWidget looks like. Obviously, if this is possible. Styles (classes that inherit QStyle) draw on behalf of widgets and encapsulate the look and feel of a GUI. setPalette(p) which needs on back when showing subLayout1, subLayout2 etc Dec 11, 2018 · One more thing last. QPalette() role Jul 21, 2017 · You can then style it: MyWidget {. I have quite a strange problem. 8 on Fedora 17 x64 27. 8, you can use a QIdentityProxyModel: Translucent Background. I will see if I am doing something wrong in my project. The following table lists the Qt widgets that can be customized using style sheets: Widget. 1 Reply Last reply . Every QWidget paints according to the palette set to it Mar 26, 2015 · I would like to independently change the background color of each page of the stacked widget (e. This works for the selected cells like having a selected row. QDialog): def __init__(self,parent=None): QtGui. You obviously don't want that. I was looking for many hours but i only found how to change the hilight color. Then press the button to the color side and select background-color, Then select the color and press the OK buttons. I currently have a stylesheet that looks like this Nov 21, 2016 · background: url ( :/myImg/1. Here is what I did to change the background color of a QComboBox: myComboBox->setStyleSheet("QComboBox { background-color: blue; }"); I haven't specifically tried for a QSpinBox, but I guess it'll work the same ! It's a 3 step process. The code apparenly should be easy: for example, here given I create a label and try to set the background to RED, but nothing happens. stylesheet += "background-color:"+highlight+"}" table->setStyleSheet(stylesheet); The selection color does the one item that is selected while the item focus will color the rest of the items that should be highlighted. with this code. Thanks again. By default, a QWidget doesn't fill its background. marouane18. ) 1. Then click on add color and choose your background color or whatever. One way I tried is below. Output: Feb 21, 2022 · The basic color, background-color, selection-color and selection-background-color properties, if set, are always installed on the widget palette with their relative color roles. I have a QWidget that has inside a QLabel, that represents an image, a separator, another QLabel and another QWidget. Apr 20, 2009 · To enable this feature in a top-level widget, set its Qt::WA_TranslucentBackground attribute with setAttribute () and ensure that its background is painted with non-opaque colors in the regions you want to be partially transparent. Widget->setStyleSheet(QString::fromUtf8("#Widget {background-color: rgb(55,55,55)};")); in ui_widget. The QStyle class is an abstract base class that encapsulates the look and feel of a GUI. g. I already tried this: Hi, I am unable to set the body background color of Main Tab and other tabs of QTab widget. ). Mar 27, 2020 · What is the RGB values for the default background color of widgets in Qt? Best. Can someone help me? @EDIT. Jul 21, 2017 · First : Click on StyleSheet. io/Threads_Events_QObjects When message loop is involved, private implementation of widgets own its children even if you don't put them into class. 4, maybe that is the problem. . QWidget(tabwidget) widget. ui->frame->setStyleSheet("color:rgb(255,255,255)"); I have tried to change the color of the QFrame by using the setStyleSheet method but no matter which Dec 1, 2019 · This is how I have set my mainLayout color self. You can set object names with the setObjectName (str) function to any Qt object, for example: for a label = QLabel (“Test”), you can write label. Is there a way to set a different background Oct 20, 2013 · Cheers. I am using the widget directly by calling . Jul 23, 2013 · Viewed 8k times. As far as I can tell applications with styled titlebars tend to be frameless windows with custom code to handle all drawing and input normally handled by the window frame. If you're only interested in setting the background color, a simple stylesheet will probably suffice: yourQTabWidget->setStyleSheet("QTabBar::tab { background-color: #FF0000; }"); A -stylesheet command line option Oct 20, 2023 · When a widget has a style sheet with a valid background or a border-image, this property is automatically disabled. You can also do it in your widgets constructor if you made a subclass. If you just want to colour the background of the tab body, then set the background role of its top-level content widget: widget = QtGui. wrote on 25 Oct 2010, 03:34. I am able to set the background color of each Tab header or tab bar. I have a QWidget -based overlay widget which should paint some text and take place over the central widget of my application. Implement a setRowColor method or/and a slot to specify color for your data rows. You can add a background image to your MainWindow by doing the following: Create a QPixmap and give it the path to your image. The following code does not work for a QTableWidgetItem that is a vertical header item, even though the same code works fine for a QTableWidgetItem that is a regular cell. qss. setGraphicsEffect(op) Feb 24, 2017 · Hi, I would suggest looking into StyleSheets. Jan 25, 2020 · Thanks, this is on win10 64bit. with them its easy to accomplish what you want in your case: the default selected background color of QTreeWidgetItem is dark-blue, i want to remove this background color and just set a red rectangle for the selected item. Here is a screen-shot of what I did to achieve the trick: Image of the application. QPalette::Base: 9: Used mostly as the background color for text entry widgets, but can also be used for other painting - such as the background of combobox drop down lists and toolbar handles. The currently selected date can be retrieved using the selectedDate () function. Styles and Style Aware Widgets. palette() p. in the paint event of the delegate you handle the color changing technique. The example shows how to make a round window with a translucent background. #8. png) } Now in this case all the child widgets also have the same image as background image. Oct 7, 2008 · To make sure your background color will be correct, I would suggest to use the Qt Style Sheet. To enable this feature in a top-level widget, set its Qt::WA_TranslucentBackground attribute with setAttribute() and ensure that its background is painted with non-opaque colors in the regions you want to be partially transparent. Jul 31, 2019 · ui->widget->setAutoFillBackground(true); ui->widget->setPalette(pal); ui->widget->show(); if you used UI files to make the app. My problem is, i tried to give the Widget a color "transparent", but it won't work as what i think May 29, 2013 · I am trying to set the background and foreground color of a QTableWidgetItem that is a Vertical Header Item in a row of my QTableWidget. To change the text color and background color of a QLabel, here is what I would do : QLabel* pLabel = new QLabel; pLabel->setStyleSheet("QLabel { background-color : red; color : blue; }"); You could also avoid using Qt Style Sheets and change the Your code is almost correct. OMG, I'm sorry I forgot to write, I'm using QTreeWidget, I was trying to set the pointer to QTreeWidgetItem with Jul 24, 2015 · 8. // GROUP1. thank you ! It turns out this is very easy to implement using Qt Style Sheets. setPalette(p) I created a separate qt project and it's working there. I implemented a custom QWidgetAction included:. for your custom widget to respect the stylesheet, the Qt::WA_StyledBackground attribute should be set to true, as it:. YourClass[customPropertyName="2"] { background-color: black; } Also it's needed to reload stylesheet of the object instance after your set new property value, because stylesheets are not recalculated automatically: Hello, I want to assign a specific background color to a specific tab header when the user receives a message from another user. PyQt is still Qt 4. El QWidget es la clase base para todos los objetos de la interfaz de usuario, lo que significa que se puede usar el mismo enfoque para cambiar el color de fondo de estos. While ::title sub-control works for borders, background-color and other box properties the text itself is styled with QDockWidget {}, without the ::title. I am trying to set the background color of a QTableWidgetItem, but it doenst work? When I try to change the textcolor, it works without any problems. /image. background: url ( ':/myImg/1. where the grid layout is). tw1= new QTabWidget ; tw1->setContentsMargins( 0, 0, 0, 0 ); tw1->setMinimumWidth( 1000 ); tw1->setMinimumHeight( 780 ); Feb 2, 2017 · I'm making simple TODO-list in Qt, i want to "check" done items by changing their background color to green. I have checked the Qt Documentation About StyleSheet and have also also checked some old questions, but none of the has served me. background-color: blue; color: yellow; qproperty-extra: "Some extra text"; } For the widget in your code sample, the background is never drawn. QCheckBox::indicator { border: 3px solid #5A5A5A; background: none; } In order to set the stylesheet you could either use the Qt Designer or the setStylesheet function. I cannot use the setStylesheet() function as it will replace any other settings. setTextBackgroundColor(QColor(0,0,0)) w. answered Jul 21, 2017 at 9:49. For Approach2 to work, i. This won't be right, though. Jul 25, 2013 · Using Qt 4. __init__(self,parent) pal=QtGui. 4 on Windows 7 (MSVC 2010) I have a standard QMainWindow in my app with a toolbar. However, at run-time it comes out with all the descendants (label, group boxes) themselves colored but not the background of the widget itself, between children (i. first page blue, second page red, etc. For another widget I used setMash to set rectangular masks and it did work. mm ap cf yv mf dg so xj gd ew