Skip to content

Instantly share code, notes, and snippets.

@cosven
Created March 18, 2019 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cosven/0d1f06cb78c79171da51bee9376f71fd to your computer and use it in GitHub Desktop.
Save cosven/0d1f06cb78c79171da51bee9376f71fd to your computer and use it in GitHub Desktop.
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
Copy link
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