Results 1 to 3 of 3

Thread: QTableWidget with overlapping cells (span)

  1. #1
    Join Date
    May 2006
    Location
    Vienna (Austria)
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QTableWidget with overlapping cells (span)

    I want to implement a reservation plan using Qt/4.1 and the document/view model. Basically, I need a table (row = room, column = day) where the reservations are inserted. These reservations can be longer than one day, i.e. they can span over more than one cell. A context menu and drag&drop shall be available for these reservations.

    Can I use QAbstractTableModel for the model and QTableWidget/QTableWidgetItem for the view? How can I realise the span? I have found QAbstractItemModel.span() but it doesn't work with Qt/4.1 yet.

    By the way, some time ago I began to implement this in Qt3 using QTable (without document/view model). Now I can't find QTable anymore, there is only Q3Table. Is QTable obsolete? If this is the case, it is certainly possible to span over multiple cells with QTableWidget.

    I hope you can give me some hints. Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget with overlapping cells (span)

    Quote Originally Posted by rhi
    Can I use QAbstractTableModel for the model and QTableWidget/QTableWidgetItem for the view? How can I realise the span? I have found QAbstractItemModel.span() but it doesn't work with Qt/4.1 yet.
    You can just map several model indices to single object. For example if you have a two-day reservation, your model should see it under two model indices (row, col) and (row, col+1).

    Quote Originally Posted by rhi
    By the way, some time ago I began to implement this in Qt3 using QTable (without document/view model). Now I can't find QTable anymore, there is only Q3Table. Is QTable obsolete?
    Yes, it's obsolete, because it doesn't support the MVC paradigm. Q3Table is a Qt4 equivalent of QTable from Qt3 (just remember to enable the qt3support module, by adding "QT += qt3support" to your .pro file).

  3. #3
    Join Date
    May 2006
    Location
    Vienna (Austria)
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTableWidget with overlapping cells (span)

    You can just map several model indices to single object. For example if you have a two-day reservation, your model should see it under two model indices (row, col) and (row, col+1).
    This is what I do now. However, I don't want 2 reservations which are shown in 2 cells but one single reservation (which is a drag & drop object - you can't drag & drop just one day of the res.) which occupies 2 days. How do I do this?

Similar Threads

  1. Sorting QTableWidget alters selectioin of cells
    By zarkzervo in forum Qt Programming
    Replies: 2
    Last Post: 8th January 2009, 14:13
  2. QTableWidget span !
    By stephanyShulter in forum Newbie
    Replies: 2
    Last Post: 27th October 2008, 14:20
  3. Focus of cells in a QTableWidget
    By SailinShoes in forum Qt Programming
    Replies: 4
    Last Post: 9th June 2008, 08:19
  4. QTableWidget, header cells margin
    By DpoHro in forum Qt Programming
    Replies: 4
    Last Post: 17th January 2008, 23:38
  5. QTableWidget swapping rows with widgets in cells
    By dnnc in forum Qt Programming
    Replies: 1
    Last Post: 24th May 2007, 14:11

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.