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. Drag & Drop event end
Forum Updated to NodeBB v4.3 + New Features

Drag & Drop event end

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.2k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    moravas
    wrote on 14 Nov 2014, 08:53 last edited by
    #1

    Hi Folks,

    I have a small application, where I'm using QTableView with QStandardItemModel. I enabled the drag & drop whithin the table.
    My problem is, that I couldn't find an lightweight, stange-forward way to detect the exact finish of drag & drop, when the model is in the final state, which is visible for the user.

    Can anybody tell me, how should I catch this?

    Regards,
    Nobert

    1 Reply Last reply
    0
    • M Offline
      M Offline
      moravas
      wrote on 20 Nov 2014, 07:53 last edited by
      #2

      Hi,

      I checked your suggestion, and I tried out with the following code:
      @
      view->horizontalHeader()->setSectionsMovable(true);
      view->verticalHeader()->setSectionsMovable(true);

      connect(view->horizontalHeader(),   &QHeaderView::sectionMoved, [this](int, int, int) {qDebug() << "horizontal";});
      connect(view->verticalHeader(),     &QHeaderView::sectionMoved, [this](int, int, int) {qDebug() << "vertical";});
      

      @

      but nothing was happening.
      could you provide me some code example, how should I use the headerView?

      Regards,
      Nobert

      can Anybody help me?

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 26 Nov 2014, 21:38 last edited by
        #3

        @
        QTableView *tableWidget = new QTableView;
        QStandardItemModel *itemModel = new QStandardItemModel;
        tableWidget->setModel(itemModel);

        itemModel->setColumnCount(4);
        itemModel->setRowCount(5);
        
        for (int col = 0 ; col < itemModel->columnCount() ; ++col) {
            for (int row = 0 ; row < itemModel->rowCount() ; ++row) {
                QStandardItem *item = new QStandardItem(tr("Test %1 %2").arg(col).arg(row));
                itemModel->setItem(row, col, item);
            }
        }
        
        tableWidget->horizontalHeader()->setSectionsMovable(true);
        tableWidget->verticalHeader()->setSectionsMovable(true);
        

        @

        With that you can move rows up and down and columns left to right

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0

        1/3

        14 Nov 2014, 08:53

        • Login

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