Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Switch widgets in a QTableWidget

Switch widgets in a QTableWidget

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TanoINF
    wrote on last edited by
    #1

    Hi everybody, I'm trying to use a QTableWidget who contains QWidget (not QItems).
    I tried to switch two widgets using Drag&Drop but I found a problem:
    -When I call the cellWidget(row,col) method I get the instance of QWidget, but the QTableWidget kept the reference to that QWidget, so when I use setCellWidget in the same (row,col) it remove the QWidget.
    An example to clearify:

    @
    //dragEnterEvent

        previousRow = rowAt(event->pos().y());
        previousCol = columnAt(event->pos().x());
        previousWidget = cellWidget(previousRow,previousCol);
    

    //dropEvent

    QWidget *currentWidget = cellWidget(currentRow,currentCol);
    setCellWidget(currentRow,currentCol,previousWidget);
    setCellWidget(previousRow,previousCol,currentWidget);
    

    @

    When I do that, I remove both QWidget... I tried to set a null pointer to the cell (setCellWidget(row,col,0) after getting the cellWidget, but It didn't work...

    Any idea? Thanks!

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved