Custom Table View Widget
-
Hey guys!
Im currently building a Bug Tracker just for fun. For that I need a custom styled QTableView. On the screenshot you can see what I want to do.
My problem is that I dont know how I achieve this. As far as I can see I cant style the QTableView that much to fit my needs. My idea was to create the header manually (the grey bar with first name, last name etc.) and then use a QScrollArea with a custom build widget to represent the data.
Is there a better way to do this? I need to use this custom TableView on multiple sites so a reusable widget/code would be really nice^^Thanks guys!
Im using QT Widgets and C++!

-
Hi,
I see three possibilities:
- Custom QStyle or a QProxyStyle
- Custom QHeaderView with paintEvent re-implemented
- Qt Stylesheet system
There's no particular order of preferences.
-
Hi,
I see three possibilities:
- Custom QStyle or a QProxyStyle
- Custom QHeaderView with paintEvent re-implemented
- Qt Stylesheet system
There's no particular order of preferences.
@SGaist
1 - So I create a new "app style" which defines how the TableView gets drawn? So I work with e.g. a Painter and other stuff related to drawing/displaying things?2 - Im replacing the QTableView header with a custom one which gets styled via stylesheet? And the TableView itself is redesigned via overwritting how it gets drawn/displayed?
3 - I tried that but I only had very limited options to style the TableView. Or what exactly do you mean with that?
Never worked with any of these (except stylesheet ofc) so I dont know them. Sorry for asking^^
-
Not the table view, the QHeaderView.
For the styling, see KDAB's Say No To Qt Style Sheets.
-
Not the table view, the QHeaderView.
For the styling, see KDAB's Say No To Qt Style Sheets.
@SGaist Never thought about these things. Seems like QStyle is by far the better choice. The only thing that is holding me back is the QT-Designer. Atm Im using VS22 with the Qt Tools. My problem is that I need to recompile and rerun the program everytime I change something small + I cant "preview" it in the Designer. Or am I wrong?
For me it looks like I shift more and more to bare C++ code until every small peace of ui stuff is coded. It makes .ui files more or less useless. You know what I mean? -
I see what you mean.
From memory, Designer allows to preview your design in different styles but I don't know how to make it use your own style beside the fact that you would need to build it with the same Qt version that was used to build designer.
-
I see what you mean.
From memory, Designer allows to preview your design in different styles but I don't know how to make it use your own style beside the fact that you would need to build it with the same Qt version that was used to build designer.
@SGaist So its a needed sacrifice? Or am I missing something?
-
Not necessarily, I currently just don't know how to make your custom style available to be used by Designer for preview.