Results 1 to 2 of 2

Thread: Change tableView vertical header

  1. #1
    Join Date
    Apr 2010
    Location
    Sudan
    Posts
    46
    Thanks
    7
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Change tableView vertical header

    Hi every one..

    How can i change QTreeView vertical header?

    the QTreeView is presenting QSqlQueryModel .

    l tried to do it this way but it did not work :

    Qt Code:
    1. QSqlQuery qury;
    2.  
    3. QSqlQueryModel tableModel;
    4.  
    5. qury.exec("select * from table;");
    6. tableModel.setQuery(qury);
    7.  
    8. ui->tableWidget->setModel(&tableModel);
    9.  
    10. for (int i=0; i<=14;i++)
    11. tableModel.setHeaderData(i, Qt::Vertical, stringList[i]);
    To copy to clipboard, switch view to plain text mode 

    this code is working fine when i use it for the Horizontal header :

    Qt Code:
    1. for (int i=0; i<=14;i++)
    2. tableModel.setHeaderData(i, Qt::Horizontal , stringList[i]);
    To copy to clipboard, switch view to plain text mode 

    any ideas ?

    thanks in advanced ..

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Change tableView vertical header

    QSqlQueryModel doesn't allow to store information in the vertical header. If I'm correct then from the built-in models only QStandardItemModel allows that. You need to subclass your model, reimplement setHeaderData() and store the data you want in some container. Then reimplement headerData() and return data from your container when requested.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Resizing vertical header in QTableView
    By p.csakany in forum Qt Programming
    Replies: 3
    Last Post: 1st November 2010, 23:06
  2. Vertical Header For QTreeView
    By wirasto in forum Qt-based Software
    Replies: 1
    Last Post: 12th October 2010, 05:53
  3. Qtableview Vertical header order
    By Darthspawn in forum Qt Programming
    Replies: 4
    Last Post: 26th March 2010, 15:10
  4. No Sort Vertical Header
    By wirasto in forum Qt Programming
    Replies: 4
    Last Post: 1st July 2009, 10:54
  5. Replies: 3
    Last Post: 1st February 2008, 18:18

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.