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. QTreeWidget - multiple columns d&d
QtWS25 Last Chance

QTreeWidget - multiple columns d&d

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 6.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.
  • S Offline
    S Offline
    Sorin
    wrote on last edited by
    #1

    I have a QTreeWidget with tree columns:

    @void MyTree::AddNewElement()
    {
    QTreeWidgetItem* treeItem = new QTreeWidgetItem( this, 0 );
    treeItem->setText( 0, "someText" );
    setItemWidget( treeItem, 1, new QToolButton( this ) );
    setItemWidget( treeItem, 2, new QToolButton( this ) );
    }@

    for this widget I want to implement d&d so all the columns should keep their content. Right now when I'm d&d only the text column keeps the content. How should I do it right?

    Thanks!

    There are only 10 types of people in the world: Those who understand binary, and those who don't

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      Drag'n'drop for item widgets is not supported out of the box.

      You would have to go with QTreeView and a customized model to make this work.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Sorin
        wrote on last edited by
        #3

        yes you're right about this, I need to do some more studying :) , I found a nice example "here":http://www.java2s.com/Code/Cpp/Qt/QTreeViewdraganddrop.htm

        There are only 10 types of people in the world: Those who understand binary, and those who don't

        1 Reply Last reply
        0
        • B Offline
          B Offline
          baysmith
          wrote on last edited by
          #4

          Does setting the following work?
          @
          MyTree::MyTree(...)
          {
          setDragEnabled(true);
          setAcceptDrops(true);
          setDragDropMode(QAbstractItemView::InternalMove);

          ...
          }
          @

          Nokia Certified Qt Specialist.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #5

            Looking at the source code of the Qt libs, the widgets (resp. their pointers) plainly don't make their way into the dragged data.

            http://www.catb.org/~esr/faqs/smart-questions.html

            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