Results 1 to 3 of 3

Thread: Reorder the columns in QSqlTableModel/QTableView?

  1. #1
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Reorder the columns in QSqlTableModel/QTableView?

    In Qt4.1.4, is there a way to dynamically reorder the columns displayed when you tie a QSqlTableModel to a QTableView? I don't seem to see a way to set the columns displayed, except by reordering the actual columns when the table is initially created in "create table" command. For instance, I might want to show the Firstname column before Lastname in one view, and Lastname before Firstname in another view.
    Last edited by gfunk; 17th July 2006 at 23:02.
    Software Engineer



  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Reorder the columns in QSqlTableModel/QTableView?

    QHeaderView::moveSection(int from, int to)
    Moves the section at visual index from to occupy visual index to.
    And you can access the header by:
    QTableView::horizontalHeader()
    J-P Nurmi

  3. The following 2 users say thank you to jpn for this useful post:

    elettronik (14th August 2011), gfunk (17th July 2006)

  4. #3
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Reorder the columns in QSqlTableModel/QTableView?

    Doh!! I feel bad, that was probably too easy for you. =P
    Thanks!
    Software Engineer



Similar Threads

  1. Maximize columns on QTableWidget
    By marcelrc in forum Newbie
    Replies: 1
    Last Post: 21st May 2006, 15:34
  2. QCheckListItem with multiple columns?
    By ecphora in forum Qt Programming
    Replies: 7
    Last Post: 12th April 2006, 05:01
  3. Replies: 6
    Last Post: 5th March 2006, 21:05
  4. Changing the order of columns in QTreeView
    By johnny_sparx in forum Qt Programming
    Replies: 1
    Last Post: 15th February 2006, 00:00
  5. Mac OS X Columns have gaps
    By square in forum Qt Programming
    Replies: 1
    Last Post: 6th February 2006, 09:40

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.