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. [SOLVED] move column in qtable view
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] move column in qtable view

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 3.1k Views 1 Watching
  • 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.
  • C Offline
    C Offline
    conceptid
    wrote on last edited by
    #1

    In Java swingx, a user can move columns of a jtable and change columns position.

    Is it possible with Qt C++ QTableView ? And QTableViewModel ?

    Or is there another datagrid class to do that?

    Maybe I don't have the right term of this feature to search in google... I found nothing about this.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      It's a bit more hidden. Try this:

      @
      QTableView * tableView = new QTableView(this);
      tableView->horizontalHeader()->setMovable(true);
      @

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • C Offline
        C Offline
        conceptid
        wrote on last edited by
        #3

        error: 'class QHeaderView' has no member named 'setMovable'

        1 Reply Last reply
        0
        • C Offline
          C Offline
          conceptid
          wrote on last edited by
          #4

          You put me on the right way... and I found:

          void QHeaderView::setMovable(bool movable)

          Use setSectionsMovable instead.

          @
          headerView->setSectionsMovable(true);
          @

          Now, it's working :)

          Thanks a lot!

          E.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Right, QHeaderView has changed a bit in the transition to Qt 5.

            You're welcome !

            Now that you have it working, please, update the thread title prepending [solved] so other forum users may know a solution has been found :)

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            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