Results 1 to 14 of 14

Thread: QTableWidget move row?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2012
    Posts
    13
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTableWidget move row?

    Hi,
    "moveSection" will move the section of the header and its contents (<- the row including QWidgets set with "setCellWidget"). But what if i want to move only the contents of the row without changing the header? More specifically, what should i do if want to swap two cells containing each of them a QWidget?

    jpn

    Re: QTableWidget move row?
    Apparently QTableWidget::setCellWidget() maps the widget to the specific cell, not to the specific item. So you will have swap the cell widget by hand, too.
    How can i swap the cell widget by hand?
    Thanx in advance

  2. #2
    Join Date
    May 2012
    Posts
    13
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTableWidget move row?

    Till now, i've manage to swap two cells with QWidgets but with a very ugly trick!
    First, i get the pointers of the two QWidgets by calling "cellWidget" (let's say wid1 and wid2). Then, i call "editorDestroyed(wid1)" and "editorDestroyed(wid2)". This protected slot releases QWidget's pointer from the internal map but does NOT delete the widget! Finally, i call setCellWidget to set the QWidgets where i want to.

    I know that this method is not cute, but it's the only i've got till now

  3. #3
    Join Date
    Apr 2017
    Posts
    2
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: QTableWidget move row?

    Damn !
    the function 'editorDestroyed' is protected and not accessible

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,315
    Thanks
    314
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QTableWidget move row?

    the function 'editorDestroyed' is protected and not accessible
    Then all you have to do is derive your own table widget class from QTableWidget and you have access to all of the protected methods of QTableWidget and its base classes. This is basic C++.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. QTableWidget Sorting Multiple Selection
    By rhiacasta in forum Qt Programming
    Replies: 1
    Last Post: 30th August 2006, 21:05
  2. QTableWidget Update - slow
    By DPinLV in forum Qt Programming
    Replies: 16
    Last Post: 18th August 2006, 21:09
  3. Move child widget along with the parent widget
    By sreedhar in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2006, 12:00
  4. Replies: 6
    Last Post: 5th March 2006, 21:05
  5. How to obtain the width of a QTableWidget?
    By Giel Peters in forum Qt Programming
    Replies: 3
    Last Post: 9th January 2006, 22:34

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
  •  
Qt is a trademark of The Qt Company.