Skip to content

Instantly share code, notes, and snippets.

@cosven cosven/app.py
Created Mar 18, 2019

Embed
What would you like to do?
qt qtableview macOS mojave dark mode bug
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()
@cosven

This comment has been minimized.

Copy link
Owner Author

cosven commented Mar 18, 2019

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.