Results 1 to 3 of 3

Thread: Drag & Drop disabling in QTreeWidget!

  1. #1
    Join Date
    Jan 2013
    Posts
    22
    Thanked 3 Times in 2 Posts
    Qt products
    Qt/Embedded

    Default Drag & Drop disabling in QTreeWidget!

    Hi,
    I tried to disable drag and drop property for QTreeWidget's Header columns.
    done m_Tree-> setDragEnabled(false);
    but still drag and drop is working.
    so how to disable drag and drop for QTreeWidget?


    Thanks,
    sanujas

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Drag & Drop disabling in QTreeWidget!

    I assume you refer to section drag and drop, well it depends on Qt version you use
    Qt Code:
    1. #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
    2. treeWidget.header()->setSectionsMovable(false);
    3. #else
    4. treeWidget.header()->setMovable(false);
    5. #endif
    To copy to clipboard, switch view to plain text mode 
    Last edited by Santosh Reddy; 3rd September 2013 at 12:13.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Jan 2013
    Posts
    22
    Thanked 3 Times in 2 Posts
    Qt products
    Qt/Embedded

    Default Re: Drag & Drop disabling in QTreeWidget!

    Hi,
    Thanks a lot,Yah it got worked with setMovable.

    One more question:
    I wanted to do Sections of Hearder(Header columns) unstretchable.
    By below code i could make first 3 columns unstretchable but 4 column is still stretchable.
    I tried to use TreeView, but it gives compilation error that setStretchLastSection is not a member of QTreeView.
    So pls let me know how can i make 4th column unstretchable?
    m_TreeWidget->setColumnWidth(0, 80);
    m_TreeWidget->setColumnWidth(1, 70);
    m_TreeWidget->setColumnWidth(2, 100);
    m_TreeWidget->setColumnWidth(3, 112);
    m_TreeWidget->header()->setStretchLastSection(false);
    m_TreeWidget->header()->setResizeMode(0,QHeaderView ::Fixed);
    m_TreeWidget->header()->setResizeMode(1,QHeaderView ::Fixed);
    m_TreeWidget->header()->setResizeMode(2,QHeaderView ::Fixed);
    m_TreeWidget->header()->setResizeMode(3,QHeaderView ::Fixed);

    Thanks,
    Sanujas

Similar Threads

  1. QTReeWidget Drag and Drop
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 5
    Last Post: 2nd June 2013, 15:15
  2. QtreeWidget drag and drop
    By addu in forum Qt Programming
    Replies: 4
    Last Post: 30th June 2009, 09:41
  3. QTreeWidget Drag and Drop
    By tommydent in forum Qt Programming
    Replies: 10
    Last Post: 25th August 2008, 15:25
  4. QTreeWidget drag/drop
    By s_a_white in forum Newbie
    Replies: 1
    Last Post: 10th February 2007, 22:04
  5. Drag and drop with QTreeWidget
    By JSPoly in forum Qt Programming
    Replies: 5
    Last Post: 6th February 2007, 22:31

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.