PDA

View Full Version : QTableWidget with overlapping cells (span)



rhi
13th May 2006, 16:32
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!

jacek
13th May 2006, 18:01
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).


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).

rhi
13th May 2006, 18:44
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?