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. Move rows of Qtreeview up and down on button click
Forum Updated to NodeBB v4.3 + New Features

Move rows of Qtreeview up and down on button click

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 3.4k 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.
  • G Offline
    G Offline
    GAURAV PANT
    wrote on last edited by
    #1

    Hi,
    I have a treeview and two buttons up and down.
    Now on clicking up button the selected row should be moved up and similarly if down button is clicked then selected row should be moved down.

    I have tried moveRow function but without any success.

    Kindly Help.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      stevenceuppens
      wrote on last edited by
      #2

      Hey,

      @
      QTreeWidgetItem* item = your_qtreewidget->currentItem();
      int row = your_qtreewidget->currentIndex().row();

      if (item && row > 0)
      {
      your_qtreewidget->takeTopLevelItem(row);
      your_qtreewidget->insertTopLevelItem(row - 1, item);
      your_qtreewidget->setCurrentItem(item);
      }
      @

      src: http://stackoverflow.com/questions/2035932/raise-and-lower-qtreewidgetitem-in-a-qtreewidget

      Steven CEUPPENS
      Developer / Architect
      Mobile: +32 479 65 93 10

      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