Created
March 18, 2019 11:49
-
-
Save cosven/0d1f06cb78c79171da51bee9376f71fd to your computer and use it in GitHub Desktop.
qt qtableview macOS mojave dark mode bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PyQt5.QtWidgets import * | |
from PyQt5.QtCore import * | |
from PyQt5.QtGui import * | |
class Model(QAbstractTableModel): | |
def __init__(self): | |
super().__init__() | |
self._data = ['miao', 'hello', 'world'] | |
def rowCount(self, _): | |
return len(self._data) | |
def columnCount(self, _): | |
return len(self._data) | |
def data(self, index, role=Qt.DisplayRole): | |
if role == Qt.DisplayRole: | |
return self._data[index.row()] | |
return QVariant() | |
class XTableView(QTableView): | |
def __init__(self): | |
super().__init__() | |
app = QApplication([]) | |
w = XTableView() | |
w.setAlternatingRowColors(True) | |
w.setModel(Model()) | |
w.show() | |
app.exec() |
Author
cosven
commented
Mar 18, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment