Results 1 to 3 of 3

Thread: How to use QColumnView with QSqlTableModel

  1. #1
    Join Date
    Mar 2011
    Posts
    7
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default How to use QColumnView with QSqlTableModel

    Hello, how I can use a QColumnView to display the items of a QSqlTableModel?

    For example, if I define something like this code:

    Qt Code:
    1. model->setTable("dataBaseTable");
    2. model->select();
    3.  
    4. QColumnView *view = new QColumnView;
    5. view->setModel(model);
    To copy to clipboard, switch view to plain text mode 

    I obtain the elements of the first column of the dataBaseTable in the left column of the view, but when I click one element in the view, how I can to see more elements in the next column view?

    Thanks

  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: How to use QColumnView with QSqlTableModel

    I think you want to use QTableView instead of QColumnView.

    What is that you want to do with QColumnView? It is normaly required for tree models not for table model.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. The following user says thank you to Santosh Reddy for this useful post:

    npascual (27th June 2013)

  4. #3
    Join Date
    Mar 2011
    Posts
    7
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to use QColumnView with QSqlTableModel

    I want to use QColumnView to show four nested lists of elements. I thought to use QSqlTableModel because I read this elements from a SQL table.

Similar Threads

  1. How do I set selection in QColumnView?
    By hazzmax in forum Qt Programming
    Replies: 1
    Last Post: 22nd February 2017, 14:04
  2. How to turn off this annoying feature of QColumnView?
    By jwieland in forum Qt Programming
    Replies: 11
    Last Post: 3rd September 2010, 18:38
  3. custom QColumnView, some questions
    By Mystical Groovy in forum Qt Programming
    Replies: 1
    Last Post: 9th October 2009, 15:03
  4. QModelIndex.column() error in QColumnView?
    By tlustoch in forum Qt Programming
    Replies: 1
    Last Post: 28th December 2008, 21:45
  5. QDirModel and QColumnView question
    By yartov in forum Qt Programming
    Replies: 3
    Last Post: 11th April 2008, 22:56

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.