The QMainWindow
below is assigned a dark-gray background-color using QSS.
I would also like to change the color of the borders and the color of the title bar.
How to achieve control of the appearance of the QMainWindow
borders and titlebar?
I would like to know how to change their colors and how to control the borders width and the title-bar's height.
from PyQt4.QtCore import *
from PyQt4.QtGui import *
appStyle="""
QMainWindow{
background-color: darkgray;
}
"""
class GUI(QMainWindow):
def __init__(self):
super(GUI, self).__init__()
self.setStyleSheet(appStyle)
if __name__ == '__main__':
if not QApplication.instance(): app=QApplication([])
w=GUI()
w.setStyleSheet(appStyle)
w.show()
w.raise_()
sys.exit(app.exec_())
Step 1: Right-click on the desktop, click Personalize to open the Settings app. Step 2: On the left pane, click Colors. On the right side, make sure that Title bars and window borders option is turned on. turn on the option labeled Automatically pick an accent color from my background.
This can be implemented in QT C++ by detecting current system theme from Windows registry and applying the Dark Window hints. A dark style in addition to this can make dark light window modes.
A sample project demonstrating this is shared here if it helps to adapt
https://envyen.com/posts/2021-10-24-QT-Windows-Dark-theme/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With