Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Li1Fan opened this issue Apr 22, 2024 · 0 comments
Open

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

Li1Fan opened this issue Apr 22, 2024 · 0 comments

Comments

@Li1Fan
Copy link

Li1Fan commented Apr 22, 2024

Describe Your Environment

  • OPERATING SYSTEM---------------------------------------------------------------
  • PYTHON DISTRIBUTION------------------------------------------------------------
    • Version....................... 3.8.10
    • C Compiler.................... GCC 9.4.0
    • C API Version................. 1013
    • Implementation................ cpython
    • Implementation Version........ 3.8.10
  • QT BINDINGS--------------------------------------------------------------------
    • PyQt5 Version................. 5.15.4
    • PyQt5 Qt Version.............. 5.15.2
    • PySide2 Version............... 5.15.2.1
    • PySide2 Qt Version............ 5.15.2
  • QT ABSTRACTIONS----------------------------------------------------------------
    • qtpy Version.................. 2.3.0
    • qtpy Binding.................. pyqt5
    • qtpy Binding Variable......... os.environ['QT_API']
    • qtpy Import Name.............. qtpy
    • qtpy Status................... OK
    • pyqtgraph Version............. 0.12.4
    • pyqtgraph Binding............. Not set or inexistent
    • pyqtgraph Binding Variable.... os.environ['PYQTGRAPH_QT_LIB']
    • pyqtgraph Import Name......... pyqtgraph
    • pyqtgraph Status.............. OK
  • PYTHON PACKAGES----------------------------------------------------------------
    • helpdev....................... 0.7.1
    • QDarkStyle.................... 3.2.3

[Versions from your environment]

  • QDarkStyle:3.2.3
  • OS:ubuntu20.04
  • Python:3.8

[If used, please inform their versions]

  • PyQt:5.15.4

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_()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant