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. Want to move a entire column in QtableWidget from Ist to Second position..
QtWS25 Last Chance

Want to move a entire column in QtableWidget from Ist to Second position..

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 4.9k 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.
  • M Offline
    M Offline
    M_31
    wrote on last edited by
    #1

    Hi All,
    I want to know ...how to move one of the column in TableWidget from Position 1 to position 2 using mouse and vice versa..

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

    @tableWidget.setDragDropOverwriteMode(true);
    tableWidget.setDragEnabled(true);
    tableWidget.setDragDropMode(QAbstractItemView::InternalMove);
    tableWidget.setSelectionBehavior(QAbstractItemView::SelectRows);@

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

      This should do the trick:

      @
      tableWidget.horizontalHeader()->setMovable(true);
      tableWidget.verticalHeader()->setMovable(true);
      @

      It enables moving of both columns and rows. Leave out the last line if you only need it for columns.

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

      1 Reply Last reply
      0
      • M Offline
        M Offline
        M_31
        wrote on last edited by
        #3

        Wow...Its wounderful.. Thanks a lot for your help..

        1 Reply Last reply
        0
        • X Offline
          X Offline
          xtingray
          wrote on last edited by
          #4

          Hi!

          I have a similar situation and I'm using the same method that you mentioned:
          @tableWidget.horizontalHeader()->setMovable(true);@

          In fact, I can move the header's cell of every column of the table using the mouse, the problem is that the cells below are not moving along with that column. So I only can move the header's cells, not the whole columns (which is my requirement).

          Any hint? Thanks.


          Qt Developer

          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