Questions tagged [qpalette]

The QPalette class contains color groups for each widget state.

The QPalette class contains color groups for each widget state.

A palette consists of three color groups: Active, Disabled, and Inactive. All widgets in Qt contain a palette and use their palette to draw themselves. This makes the user interface easily configurable and easier to keep consistent.

The color groups:

  • The Active group is used for the window that has keyboard focus.
  • The Inactive group is used for other windows
  • The Disabled group is used for widgets (not windows) that are disabled for some reason.
34 questions
1
vote
3 answers

Qt use palette color in stylesheet

In qt you normally set the color of a QWidget with the QPalette. Example: QPalette palette = new QPalette(); palette.setBrush(QPalette::Base, this->palette().backgorund()); QLineEdit *line = new QLineEdit(); line->setPalette(palette); Now I have a…
NelDav
  • 785
  • 2
  • 11
  • 30
1
vote
1 answer

How to use QPROPERTY in QPalette?

I'm trying to use a Q_PROPERTY set in my stylesheet to change the value in QPalette, is this possible? For example, if I set QStyle to Fusion in my MainWindow widget, is it possible to change Qt::Window, etc using this method? Everything compiles…
RyuMake
  • 25
  • 3
1
vote
1 answer

How to get QWidget background-color after set a QStyleSheet

I have my desktop QApplication (Qt 5.9) on which I successfully set a style using a stylesheet. At runtime every QWidget look correctly styled as intended. What I need to know is the background-color of a specific styled widget, let's say a…
Sneezeface
  • 23
  • 1
  • 5
1
vote
1 answer

How do you remove a QPalette from a QWidget

According to Qt's QWidget documentation: QWidget propagates explicit palette roles from parent to child. If you assign a brush or color to a specific role on a palette and assign that palette to a widget, that role will propagate to all the…
Troyseph
  • 4,960
  • 3
  • 38
  • 61
1
vote
1 answer

How to change current color group for QPalette

I'm trying to change the current color group fora QPalette, but it seems that the setCurrentColorGroup method of QPalette simply does not work. I'm running this code: app = QtGui.QApplication(sys.argv) button = QPushButton() svgWidget =…
Guillermo Ares
  • 197
  • 1
  • 12
1
vote
1 answer

Get QPushButton Pressed Background Color

How can I get the pressed background color of a QPushButton? if (isDown()) _BGColor = ; // how to get this??? else _BGColor = palette().color(QPalette::Background); // this is to get the idle backcolor Thanks in…
Toots
  • 21
  • 3
1
vote
2 answers

Qt - render QFrame with image as background without using WA_TranslucentBackground

I need to set a QFrame with a background image: https://i.stack.imgur.com/2I3aG.jpg. This is what I tried: setAutoFillBackground(true); setWindowFlags(Qt::FramelessWindowHint); setStyleSheet("background: transparent;"); QPalette p =…
SexyBeast
  • 7,913
  • 28
  • 108
  • 196
1
vote
1 answer

How to get groups and roles of a QPalette in PyQt/PySide?

Instead of "manually" defining lists groups and roles (in my code below), how can I query the PyQt/PySide application for these values? from PyQt4 import QtGui groups = ['Disabled', 'Active', 'Inactive', 'Normal'] roles = [ …
fredrik
  • 9,631
  • 16
  • 72
  • 132
0
votes
0 answers

How to determine current border color of QGroupBox?

I am using Qt 6.3 on Windows 11, and I am trying to figure out the current border color of QGroupBox in Fusion style. I have subclassed QProxyStyle as my class GuiStyle, in my MainWindow constructor: ui.setupUi(this); auto guiStyle = new…
Chaitanya
  • 177
  • 2
  • 9
0
votes
0 answers

QPalette and app.setStyleSheet() not impacting child Widget colors

I've got a pretty large PyQt5 application that I'm finally polishing with some colors. I've created a QPalette() and pass that to the app at launch. For the most part, it works (yay!). But not all of the child widgets are picking up the QPalette…
A_Wunder
  • 96
  • 1
  • 7
0
votes
1 answer

How Can I Prevent Qt Designer from Applying QPalette to QComboBox - Python

Qt Designer builds a QComboBox that apparently prohibits an editable QComboBox from highlighting when a user double-clicks on the text displayed in the window. I’d like to have the text highlighted when double clicking in it. After converting the…
slalomchip
  • 779
  • 2
  • 9
  • 25
0
votes
2 answers

QPalette does not change the background of the button

I have the problem that the background of the button cannot be changed. Only the border is changed. I assumed that some attribute prevented this. But I think I'm wrong on that point. I've gone through the Qt documentation but can't find anything. I…
BanAnn
  • 159
  • 1
  • 7
0
votes
0 answers

QPalette propagation to QDialog not working

I have set a dark theme on my QWidget. In that widget I call a QDialog. The dialog appears in default palette which is light. This is my custom dialog (Which in this case is for choosing colors for palette! Twisted right?) .cpp file: #include…
Mohammad Rahimi
  • 965
  • 5
  • 15
0
votes
2 answers

Setting the colour of individual tabs within a QTabWidget

I need the user to be able to customize the tabs completely, I.E. right click on each tab and be able to bring up a colour palette which will allow them to change the colour of that individual tab. To do this, I've re-implemented the paintEvent…
0
votes
1 answer

Distinguish alternating rows color from selection color in QTableWidget

I have two QTableWidgets, that should synchronize their selection. More precisely everything selected in Table 2, should be automatically selected in Table 1. Everything works fine, but if I'm setting the property setAlternatingRowColors to true, I…
Aleph0
  • 5,816
  • 4
  • 29
  • 80