Palette colors of QLineEdit widget disappear on inactive window
-
wrote on 24 Jul 2018, 22:48 last edited by
Hello,
I am successfully setting the background of a QLineEdit widget for a status indication using:
... create brushes for the roles QPalette.WindowText, QPalette.Window and then...
widget.setPalette(palette)My problem is that when the user clicks outside of the main app window (makes the app the inactive window), the colors for the QLineEdit widget reverts back to its original color palette. When the window is click on (made the active window), the updated color palette reappears on the QLineEdit widget.
Is this behavior because widget.setAutoFillBackground(True) ?
What am I missing here?
Thank you for any insight and advice.
-
Thanks for the tip! Below is my method for setting the brush. I thought it was the basic way of doing it, but, I will look into using the QPalette::ColorGroup.
palette = QPalette() brush = QBrush(QColor(pR, pG, pB)) brush.setStyle(Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.Window, brush) pWidget.setPalette(palette)
Hi
I think it goes back to normal looking when it looses focus as u only set
QPalette.Active
and docs says
The color groups:
The Active group is used for the window that has keyboard focus.
The Inactive group is used for other windows.so i think u need to set for inactive too to keep look when user click outside.
(and keyboard focus goes else where) -
Hello,
I am successfully setting the background of a QLineEdit widget for a status indication using:
... create brushes for the roles QPalette.WindowText, QPalette.Window and then...
widget.setPalette(palette)My problem is that when the user clicks outside of the main app window (makes the app the inactive window), the colors for the QLineEdit widget reverts back to its original color palette. When the window is click on (made the active window), the updated color palette reappears on the QLineEdit widget.
Is this behavior because widget.setAutoFillBackground(True) ?
What am I missing here?
Thank you for any insight and advice.
@David-Jacobson
how do you exactly set the brushes to the palette?
Note theQPalette::ColorGroup
parameter in the setBrush() method! -
@David-Jacobson
how do you exactly set the brushes to the palette?
Note theQPalette::ColorGroup
parameter in the setBrush() method!wrote on 25 Jul 2018, 16:20 last edited byThanks for the tip! Below is my method for setting the brush. I thought it was the basic way of doing it, but, I will look into using the QPalette::ColorGroup.
palette = QPalette() brush = QBrush(QColor(pR, pG, pB)) brush.setStyle(Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.Window, brush) pWidget.setPalette(palette)
-
Thanks for the tip! Below is my method for setting the brush. I thought it was the basic way of doing it, but, I will look into using the QPalette::ColorGroup.
palette = QPalette() brush = QBrush(QColor(pR, pG, pB)) brush.setStyle(Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.Window, brush) pWidget.setPalette(palette)
Hi
I think it goes back to normal looking when it looses focus as u only set
QPalette.Active
and docs says
The color groups:
The Active group is used for the window that has keyboard focus.
The Inactive group is used for other windows.so i think u need to set for inactive too to keep look when user click outside.
(and keyboard focus goes else where) -
Hi
I think it goes back to normal looking when it looses focus as u only set
QPalette.Active
and docs says
The color groups:
The Active group is used for the window that has keyboard focus.
The Inactive group is used for other windows.so i think u need to set for inactive too to keep look when user click outside.
(and keyboard focus goes else where)wrote on 25 Jul 2018, 16:36 last edited byAnd your tips provided my solution. Thank you. I simply added the following setbrush...
palette.setBrush(QPalette.Inactive, QPalette.Window, brush)
4/5