View Full Version : custom table widget: possible?

10th September 2012, 14:38

i implemented a custom gui widget for a software i am working on, but was wondering if there`s maybe a better way.
The widget i need is a complex widget to visually represent a bunch of custom data.
It`s ordered in rows and columns, just like a list or table view.

But: i have to render custom graphical content to every cell AND i have to render all the content, ie all the cells, at once.
Another problem is, that the amount of rows is not fixed and known but depends on multiple factors, most importantly the preceding rows.
I would also have to draw custom connections (lines, arrows, ...) across multiple cells.
To top it off, the view has to be constantly refreshed, so speed is an issue, too.

The software was actually written for another gui toolkit, where especially the bolded factor could not be implemented.
Thus, a custom widget was written which provides all this, including custom drawn columns, etc.

When i ported all this to Qt, i didnt spend much though on whether there was a better way, but copied it 1:1, using a QAbstractScrollArea as a base class.
This works fine.
But in the meantime, i have seen so much of Qt`s power that i keep thinking: there`s gotta be a better way to do this, making use of a pre-defined table widget or something.

I checked out all the table views i could find (tablewidget, listwidget, table view, list view), but i was unable to find anything on drawing all cells at once in one handler and on drawing content across the whole thing.

does anyone have hint/tips/ideas on this? :)

Santosh Reddy
11th September 2012, 05:33
You can derive your table from QTableView and reimplment the cell painting (custom cell paintings). Try searching the forum for "custom QTableView"