Search code examples
pythonhtmlpyqthtml-tableqt-quick

HTML-like tables in pyqt


I'm currently starting a little program in python and pyqt. I have little to no experience on GUI programming but I need a table to present some items (like one in this website HERE ). I was wondering if there was any way to do this in pyqt (qtquick would be better) .

I know there is qtableview in pyqt but I need to make it look like an html table. Can Qtableview be made to look like a CSS style HTML table?


Solution

  • Since QTableViews inherit from QWidgets you can just use the setStyleSheet method to override any default styles for the table.

    Depending on how you want to style the table specifically, you'll definitely want to review the Qt Style Syntax.

    As per the comment, if you just want to disable sorting call yourTable.setSortingEnabled(False), and call yourTable.verticalHeader().setMovable(False) (or horizontalHeader) to disable moving the headers, when creating the table.