Results 1 to 2 of 2

Thread: Want to move a column in QtableWidget from Ist to Second position using mouse

  1. #1
    Join Date
    Jul 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Want to move a column in QtableWidget from Ist to Second position using mouse

    Hi All,
    I want to know ...how to move a column in QTableWidget from Position 1 to position 2 using mouse..

    I tried with the following function , but it was not working ..

    tableWidget.setDragDropOverwriteMode(true);
    tableWidget.setDragEnabled(true);
    tableWidget.setDragDropMode(QAbstractItemView::Int ernalMove);
    tableWidget.setSelectionBehavior(QAbstractItemView ::SelectRows);

  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: Want to move a column in QtableWidget from Ist to Second position using mouse

    You need to set the sections as movable in horizontal header (i.e. QHeaderView) of the QTableWidget
    Qt Code:
    1. QTableWidget * table = new QTableWidget(this); // or QTableView
    2. table->horizontalHeader()->setMovable(true);
    3.  
    4. QTreeWidget * tree = new QTreeWidget(this); // or QTreeView
    5. tree->header()->setMovable(true);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 1
    Last Post: 15th April 2010, 14:56
  2. Move Rectangle on mouse Move
    By vermarajeev in forum Qt Programming
    Replies: 24
    Last Post: 14th May 2007, 06:34
  3. Fixing default Window position with move.
    By VireX in forum Qt Programming
    Replies: 4
    Last Post: 3rd April 2007, 22:13
  4. Replies: 0
    Last Post: 10th November 2006, 14:46
  5. move qTextBrowser to Home Position
    By klaus1111 in forum Qt Programming
    Replies: 3
    Last Post: 15th July 2006, 14:09

Tags for this Thread

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.