PDA

View Full Version : how to merge two adjacent grids of a QTableWidget into one?



bookmarkernj
6th July 2007, 03:41
Hi, everybody:
How to merge two grids of QtableWidget instance into one grid?
thanks.:confused:

jpn
7th July 2007, 08:35
How to merge two grids of QtableWidget instance into one grid?
The question is, how do you want to merge them? Merging is quite an abstract concept. :)

Anyway, with QTableWidget there is no other way around than just doing it by hand (ie. copying data from table to another). However, if merging means showing data of both tables next to each other in a single table, using model-based approach would certainly help in achieving a more elegant solution. The underlying model could be same in all views; the two distinct tables could have part of rows/columns hidden and the result table could show it all.

bookmarkernj
7th July 2007, 16:49
I'm sorry, Maybe I did not make that clear.
Now , let's do some explaining.
I'm doing a cluster monitoring software whose gui uses Qt(now I use Qt 4.2), I want to use QTableWidget to express some kind of information of every node in cluster, for example, I want to use a row to express a node's nodeName, each cpu's efficiency, active state. Now the problem comes, a computer node may have several cpus( eg. two cpus) , but only has one active state( active or inactive), diagram as following:
___________________
|Node1 | 90% | ON |
| |-----------| |
| | 50 % | |
----------------------------------
what can I do use QTableWidget to implement the above thing ?:confused:

jpn
7th July 2007, 17:20
Ahh, so you want to merge cells, not whole tables. :) Try making use of QTableView::setSpan(). I'm not sure if I ever tried it with Qt 4.2 but at least with Qt 4.3.0 it seems to work pretty nicely.