ColinDuquesnoy / QDarkStyleSheet

A dark style sheet for QtWidgets application
Other
2.84k stars 731 forks source link

The font size of the table header cannot be adjusted #348

Open Li1Fan opened 7 months ago

Li1Fan commented 7 months ago

Describe Your Environment

[Versions from your environment]

[If used, please inform their versions]

Language

Python

Description / Steps to Reproduce [if necessary]

[Description of the issue]

  1. run the following code. I want the font size of the table header to follow the actual font size change, but it doesn't.

Actual Result

[A description, output ou image of the actual result]

Expected Results / Proposed Result

[A description, output ou image of the expected/proposed result]

Relevant Code [if necessary]

[A piece of code to reproduce and/or fix this issue]

import qdarkstyle
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import QApplication, QTableWidget, QPushButton, QTableWidgetItem, QVBoxLayout, QWidget

class MyWindow(QWidget):
    def __init__(self, app=None):
        super().__init__()
        self.setWindowTitle("sample")
        self.table = QTableWidget()
        self.button = QPushButton("click me!")

        self.layout_ = QVBoxLayout()
        self.layout_.addWidget(self.table)
        self.layout_.addWidget(self.button)
        self.setLayout(self.layout_)

        self.setup_table()
        self.setup_button()

        self.app = app

    def setup_table(self):
        self.table.setGeometry(50, 50, 100, 200)
        self.table.setRowCount(4)
        self.table.setColumnCount(4)
        for row in range(4):
            for col in range(4):
                item = QTableWidgetItem(str((row + 1) * (col + 1)))
                self.table.setItem(row, col, item)

    def setup_button(self):
        self.button.setGeometry(50, 270, 100, 30)
        self.button.clicked.connect(self.on_button_clicked)

    def on_button_clicked(self):
        font = QFont()
        font.setPointSize(30)
        self.app.setFont(font)
        self.app.setStyleSheet(app.styleSheet())

if __name__ == '__main__':
    app = QApplication([])
    window = MyWindow(app)
    window.resize(500, 400)
    window.show()

    font = QFont()
    font.setPointSize(20)
    app.setFont(font)

    palette = qdarkstyle.Palette()
    palette.ID = 'light'
    app.setStyleSheet(qdarkstyle._load_stylesheet(qt_api='pyqt5', palette=palette))

    app.exec_()