5yutan5 / PyQtDarkTheme

A flat dark theme for PySide and PyQt.
https://pyqtdarktheme.readthedocs.io
MIT License
568 stars 89 forks source link

Titelbar of QDockWidgets #261

Open sennah-github opened 4 months ago

sennah-github commented 4 months ago

This stripped down code creates a QApplication containing a QDockWidget:

from PyQt6 import QtWidgets, QtGui
from PyQt6.QtWidgets import QApplication, QMainWindow, QDockWidget, QWidget, QVBoxLayout, QWidget, QPlainTextEdit
from PyQt6.QtCore import Qt, QSettings, QByteArray

class myQWidget(QWidget):
    def __init__(self, name = "Widget"):
        super().__init__()
        self.setObjectName (name)
        self.layout = QVBoxLayout()
        self.line_edit = QPlainTextEdit(name)
        ### INIT ###
        self.layout.addWidget(self.line_edit)
        self.setLayout(self.layout)

class myQDockWidget(QDockWidget):
    def __init__(self, title = "", name = "DockWidget"):
        super().__init__()
        self.setObjectName(name)
        self.widget = myQWidget(name)
        ### INIT ###
        self.setWindowTitle(title)
        self.setWidget(self.widget)

if __name__ == "__main__":
    class MainWindow(QMainWindow):
        def __init__(self):
            super().__init__()
            self.setObjectName("MyMainWindow")
            self.widget = myQWidget(name="My Widget")
            self.dock_widget = myQDockWidget(title= "My Dock Widget", name = "MyDockWidget")
            ### INIT ###
            self.setCentralWidget(self.widget)
            self.addDockWidget(Qt.DockWidgetArea.RightDockWidgetArea, self.dock_widget)
            self.dock_widget.setAllowedAreas(Qt.DockWidgetArea.RightDockWidgetArea|Qt.DockWidgetArea.LeftDockWidgetArea)
            self.setWindowTitle("My Main Window")

    import sys
    import qdarktheme
    app = QApplication(sys.argv)
    qdarktheme.setup_theme("auto")
    app.ObjectName = "My App"
    window = MainWindow()
    window.show()
    sys.exit(app.exec())

As you can see the title bar of the QDockWidget (Title: "My Dock Widget") is to big. How can I make it thinner and the two icons smaller?

Here's a screen shot of the sample supplied with the PyQtDarktheme module and my small app on top:

Unbenannt