Results 1 to 10 of 10

Thread: swap cell widgets on QTableWidget

  1. #1
    Join Date
    May 2008
    Posts
    24
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11

    Default swap cell widgets on QTableWidget

    Hi all !

    I want to swap cell widgets. I have used cellWidget to get the widget of cell, insertRow to create the purposed row, setCellWidget to assign the widget to the new row, and removeRow to delete the current row.

    However deleting the old one deletes also the cell widget at the purposed row.

    I have looked for the archive and found this http://www.qtcentre.org/forum/f-qt-p...post18492.html but still unanswered

    Any helps would be highly appreciated. Thank you.

  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: swap cell widgets on QTableWidget

    What do you need those cell widgets for? Maybe there's a better way to do it without cell widgets? Cell widgets don't integrate to the table very well, they are just something laid on top of the view. And they are expensive to maintain. I'd advice against using them in the first place...
    J-P Nurmi

  3. #3
    Join Date
    May 2008
    Posts
    24
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: swap cell widgets on QTableWidget

    I need those widgets for graphically assinging the order of tasks (please see the attached figure). The code was originally written with Qt3 and will be now ported to Qt4.

    In fact I have tried to used the Q3Table for supporting the Qt3's QTable, but the widgets are somehow freezed when the window size is altered. That's why I have decided to use Qt4. However, I should keep as most lines of code as possible.
    Attached Images Attached Images

  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: swap cell widgets on QTableWidget

    Where's the table and what is it used for? All I can see is a layout of widgets...
    J-P Nurmi

  5. #5
    Join Date
    May 2008
    Posts
    24
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: swap cell widgets on QTableWidget

    That is the table with type of QTableWidget. The table has two columns and, at the beginning only one row with the 'Subtask' widget as the fix one. The other task widgets, each widget for each row, are added by request. The order of task widgets, except the 'Subtask', should be able to alter: up or down.

    Also, in Qt3, this altering order can be done perfectly by applying function swapCells(), which is no longer available on Qt4. That is the main problem.

    Any idea ?

  6. #6
    Join Date
    May 2008
    Posts
    24
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: swap cell widgets on QTableWidget

    Should I use QTableView rather than QTableWidget because of having cell widgets ? I know that the latter inherits the former and works with default model. In other words, QTableView should be used for working with a table using own data model.

    Unfortunately I am not sure that in my case this is the answer.

    Any helps would be highly appreciated.

  7. #7
    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: swap cell widgets on QTableWidget

    My point was that I don't see the table used for anything but "layouting" the widgets. As I said, filling a table with cell widgets is not optimal. Do you actually use any table specific features? Shouldn't you use a layout to do layouting?
    J-P Nurmi

  8. #8
    Join Date
    May 2008
    Posts
    24
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: swap cell widgets on QTableWidget

    The table is not shown because of the thickness of the border line of each cell. In order to make easier to recognize the table, please see the attachment. The border lines are in red. In this case, I have 3 rows and 2 columns.

    The property of table used in this case is the index of row, which is representing the order of tasks. The Subtask widget is fixed at the bottom.

    I am not sure that Layout can handle such a problem. When so, which one ?
    Attached Images Attached Images

  9. #9
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: swap cell widgets on QTableWidget

    My guess would be to use e.g. QScrollArea with grid layout if you dont need model (as I understand it right).
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  10. #10
    Join Date
    May 2008
    Posts
    24
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: swap cell widgets on QTableWidget

    I have decided to be back to use of Q3Table. The freezing problem occuring whenever the size window is altered is solved by means of function resizeEvent().

    Thanks anyway.

Similar Threads

  1. Problems with QString
    By cyberboy in forum Qt Programming
    Replies: 2
    Last Post: 13th October 2008, 08:18
  2. Replies: 0
    Last Post: 2nd May 2008, 07:57
  3. QTableWidget : insert multiple widgets in one cell..
    By halberdier83 in forum Qt Programming
    Replies: 3
    Last Post: 26th November 2007, 16:15
  4. QTableWidget swapping rows with widgets in cells
    By dnnc in forum Qt Programming
    Replies: 1
    Last Post: 24th May 2007, 14:11
  5. Word wrapping in a QTableWidget cell
    By jcooperddtd in forum Qt Programming
    Replies: 3
    Last Post: 1st May 2007, 03:57

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.