Results 1 to 13 of 13

Thread: QtTreeWidget: issue with indicator display

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QtTreeWidget: issue with indicator display

    Qt Code:
    1. QTreeWidget* tree = new QTreeWidget( this );
    2. tree->setDragEnabled( true );
    3. tree->setAcceptDrops( true );
    4. tree->setDropIndicatorShown( true );
    5. tree->setDefaultDropAction( Qt::MoveAction ); // that's what you need
    To copy to clipboard, switch view to plain text mode 
    This should do it. No need to set setDragDropMode() as setDragEnabled() and setAcceptDrops() do it for you.

  2. #2
    Join Date
    Jun 2010
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QtTreeWidget: issue with indicator display

    Hi, thanks for your answer.

    The problem is that calling
    Qt Code:
    1. setDefaultDropAction( Qt::MoveAction );
    To copy to clipboard, switch view to plain text mode 
    leads to the following behaviour: I can't insert my items between two existing nodes anymore (indicator=line), all I can do is to move the item as a child (indicator=rectangle). Does that make sense ?

    Moving/copying by inserting the item between two existing items was possible before.

    Any idea ?

  3. #3
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QtTreeWidget: issue with indicator display

    What you mean you can't insert the items?
    Does the line indicator appear but nothing happens?

    This works fine for me:
    Qt Code:
    1. MainWindow::MainWindow( QWidget* p )
    2. :
    3. {
    4. QTreeWidget* tree = new QTreeWidget( this );
    5. tree->setDragEnabled( true );
    6. tree->setAcceptDrops( true );
    7. tree->setDropIndicatorShown( true );
    8. tree->setDefaultDropAction( Qt::MoveAction );
    9.  
    10. for( int i = 0; i < 5; i++ )
    11. {
    12. QTreeWidgetItem* root = new QTreeWidgetItem( tree->invisibleRootItem() );
    13. root->setText( 0, "root" + QString::number( i ) );
    14.  
    15. for( int j = 0; j < 5; ++j )
    16. {
    17. QTreeWidgetItem* leaf = new QTreeWidgetItem( root );
    18. leaf->setText( 0, "Leaf " + QString::number( j ) );
    19. }
    20. }
    21.  
    22. this->setCentralWidget( tree );
    23. }
    To copy to clipboard, switch view to plain text mode 
    See if this example has the same issue you're experiencing.
    You may need to upgrade it to use mime types, if you do and are able to replicate the issue - post the code here.

  4. #4
    Join Date
    Jun 2010
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QtTreeWidget: issue with indicator display

    OK, your example worked for me.
    I have managed to fix my issue: actually the widget was being defined using Qt Designer, where some properties were set for that widget.
    So, basically, to avoid confusion I've cleared all the properties defined in Qt Designer, and this seems to work now.

    I think I now rather owe you a barrel of beer

    Thanks a lot for your help, that was really appreciated.

  5. #5
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QtTreeWidget: issue with indicator display

    I'm glad I could help.

    Take care!

Similar Threads

  1. QRadiButton and QCheckBox Indicator Box Sizing Issue.
    By savaliya_ambani in forum Qt for Embedded and Mobile
    Replies: 4
    Last Post: 27th August 2011, 00:56
  2. checkbox implementation in QTableWidget display issue
    By prajesh in forum Qt Programming
    Replies: 11
    Last Post: 26th February 2010, 09:35
  3. Replies: 8
    Last Post: 27th April 2009, 19:19
  4. Tray context menu display issue
    By r2hubert in forum Qt Programming
    Replies: 1
    Last Post: 7th July 2008, 20:15
  5. Drop Indicator
    By guilugi in forum Qt Programming
    Replies: 2
    Last Post: 18th January 2006, 10:49

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.