Comments (1)
Describe Your Environment
QDarkStyle: 3.0.2 and also 3.1 from PyPi
OS: Windows 10 22H2
Language
Python 3.9.12
PyQt5 5.15.7
Description / Steps to Reproduce [if necessary]
Vertical and horizontal header font and font size in QTableView are not adjusted if QDarkStyle is used . Changes are as expected if standard style is used.
minimum working example:
# inspired by https://www.pythonguis.com/tutorials/qtableview-modelviews-numpy-pandas/
import sys
import numpy as np
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import Qt
import qdarkstyle
class TableModel(QtCore.QAbstractTableModel):
def __init__(self, data, horizontal_headers,**kwargs):
super(TableModel, self).__init__()
self._data = data
self._horizontal_headers = horizontal_headers
if 'font' in kwargs.keys():
self._font = QtGui.QFont(kwargs['font'])
else:
self._font = QtGui.QFont()
if 'fontsize' in kwargs.keys():
self._font.setPixelSize(kwargs['fontsize'])
else:
self._font.setPixelSize(12)
def data(self, index, role) -> str:
"""method for visualization of the data model"""
# display
if role == Qt.DisplayRole:
datum = self._data[index.row(),index.column()]
return str(datum)
# set fonts
if role == Qt.FontRole:
return self._font
def rowCount(self, index):
return self._data.shape[0]
def columnCount(self, index):
return self._data.shape[1]
def headerData(self, section, orientation, role):
# section is the index of the column/row.
if role == Qt.DisplayRole:
if orientation == Qt.Horizontal:
return str(self._horizontal_headers[section])
if orientation == Qt.Vertical:
return str(section)
# set fonts for headers
if role == Qt.FontRole:
return self._font
class MainWindow(QtWidgets.QMainWindow):
def __init__(self):
super().__init__()
self.table = QtWidgets.QTableView()
data = np.array([
[4, 9, 2],
[1, 0, 0],
[3, 5, 0],
[3, 3, 2],
[7, 8, 9],
],dtype=int)
self.model = TableModel(data,['A','B','C'],font='Arial', fontsize=9)
self.table.setModel(self.model)
self.setCentralWidget(self.table)
if __name__ == "__main__":
app=QtWidgets.QApplication(sys.argv)
dark_stylesheet = qdarkstyle.load_stylesheet_pyqt5()
app.setStyleSheet(dark_stylesheet)
window=MainWindow()
window.show()
app.exec_()
Actual Results
Header do not change by request.
Expected Results / Proposed Result
Headers should change font and font size as well as table data.
Commenting out
dark_stylesheet = qdarkstyle.load_stylesheet_pyqt5()
app.setStyleSheet(dark_stylesheet)
and using standard style works as intended.
from qdarkstylesheet.
Related Issues (20)
- Creating a custom palette HOT 7
- djef HOT 3
- Qwt legend can't fully displayed when dock to right
- QColorDialog problem HOT 1
- qdarkstyle work conflict with mouseMoveEvent HOT 1
- QDateEdit Popup too small, wrong colors for weekends
- Incorrect modification to warnings HOT 1
- QMessageBox buttons too narrow
- Widgets inside a QToolBox are not displayed properly when placed in a QToolBox
- Improve C++ use case explanation in documentation HOT 2
- Custom style of specific widget HOT 4
- Cannot Get QTTabbar Tab Font to Change Color
- QMenu section text not visible
- Release 3.2 HOT 4
- Regression in 3.2: sass.CompileError: Error: Undefined variable: "$COLOR-DISABLED". HOT 9
- No checked hint of checkable actions inside menu entries HOT 7
- Dark theme in version 3.2.1 is not working HOT 3
- "SetuptoolsDeprecationWarning: Invalid dash-separated options" during python package build
- BUG: Cannot use 3.2.2 on PySide2 (probably anything other than PyQt5) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qdarkstylesheet.