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. How to set QTableView columns position
Qt 6.11 is out! See what's new in the release blog

How to set QTableView columns position

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 821 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.
  • D Offline
    D Offline
    Dashie
    wrote on last edited by
    #1

    I have a QTableView, with QSqlRelationalTableModel as a model providing datas.

    My database (sqlite) was like :
    1 id / 2 date / 3 time / 4 identifiant / 5-6-7-8... others fields
    I 've added a new column : x identifiant2, which is AFTER all others.

    Then in my Table it is shown at the end (was expecting that since it use the db model).

    I want to re-order columns to be displayed as "id date time identifiant identifiant2 whatever foo bar baz".

    How i can achieve that ?

    I've tried to find something but all i got in the web is about sorting rows by columns... thanks.

    1 Reply Last reply
    0
    • B Offline
      B Offline
      bsomervi
      wrote on last edited by
      #2

      I believe QHeaderView::moveSection(int from, int to) is your friend.

      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