Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change color of QMainWindow borders and title bar?

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.

enter image description here

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_())
like image 557
alphanumeric Avatar asked Feb 12 '15 15:02

alphanumeric


People also ask

How do I change the border color in Windows?

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.


Video Answer


1 Answers

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/

like image 175
Naveen Avatar answered Sep 19 '22 04:09

Naveen