-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
6.9.2
-
None
When using QAbstractTableModel to return data including emoji to then be rendered by a QTableView, the resulting table appears to simply not show the cells which contain emoji:
However, if we expand the height of the cells somewhat, we see that the data are there, but have a large amount of vertical padding:
Sample code:
from typing import override from PySide6.QtCore import ( QAbstractTableModel, QModelIndex, QObject, QPersistentModelIndex, Qt, ) from PySide6.QtWidgets import ( QApplication, QHeaderView, QTableView, QVBoxLayout, QWidget, ) TOP_LEVEL_INDEX = QModelIndex() class DemoModel(QAbstractTableModel): def __init__(self, parent: QObject | None = None) -> None: super().__init__(parent=parent) self._data = [ ("Foo", "Bar", "Baz"), ("Spam", "🍖", "Eggs"), ("Red ❤️", "G💚r💚e💚e💚n", "Blue 💙"), ("⍼", "妛彁", "🂡🂢🂣🂤🂥"), ] @override def rowCount(self, /, parent: QModelIndex | QPersistentModelIndex = TOP_LEVEL_INDEX) -> int: return len(self._data) @override def columnCount(self, /, parent: QModelIndex | QPersistentModelIndex = TOP_LEVEL_INDEX) -> int: return len(self._data[0]) @override def data( self, index: QModelIndex | QPersistentModelIndex, /, role: int = Qt.ItemDataRole.DisplayRole ) -> str | None: match role: case Qt.ItemDataRole.DisplayRole: return self._data[index.row()][index.column()] case _: return None class DemoTableView(QTableView): def __init__(self, parent: QWidget | None = None) -> None: super().__init__(parent=parent) self.setModel(DemoModel(self)) self.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.ResizeToContents) class DemoWidget(QWidget): def __init__(self, parent: QWidget | None = None) -> None: super().__init__(parent=parent) layout = QVBoxLayout(self) table_view = DemoTableView(self) layout.addWidget(table_view) if __name__ == "__main__": app = QApplication() window = DemoWidget() window.show() app.exec()
I'm experiencing this issue while using the PySide6 Python bindings, however I'm filing it here since I don't have any reason to believe this is an issue with PySide6 specifically. If I've made a mistake in this report, please let me know