Results 1 to 4 of 4

Thread: how to merge two adjacent grids of a QTableWidget into one?

  1. #1
    Join Date
    Jul 2007
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question how to merge two adjacent grids of a QTableWidget into one?

    Hi, everybody:
    How to merge two grids of QtableWidget instance into one grid?
    thanks.
    Last edited by bookmarkernj; 6th July 2007 at 04:50.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: how to merge two adjacent grids of a QTableWidget into one?

    Quote Originally Posted by bookmarkernj View Post
    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.
    J-P Nurmi

  3. #3
    Join Date
    Jul 2007
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Smile Re: how to merge two adjacent grids of a QTableWidget into one?

    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 ?

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: how to merge two adjacent grids of a QTableWidget into one?

    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.
    J-P Nurmi

  5. The following user says thank you to jpn for this useful post:

    bookmarkernj (8th July 2007)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.