Results 1 to 4 of 4

Thread: show User Defined Header Labels in QTableView

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2010
    Posts
    100
    Thanks
    38
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default show User Defined Header Labels in QTableView

    Hello every one i have a QTableView in which i am displaying data from the sql database.. I am stuck at a small problem i wanted to display Header names for all the channel's which i have appended in a QStringList. I tried many things but i get the database table column name's as the header's.

    Qt Code:
    1. QSqlQueryModel *model = new QSqlQueryModel(tableView);
    2. model->setQuery("SELECT "+ colNames +" from thdata where rowid = (select max(rowid) from thdata)");
    3. tableView->setModel(model);
    4. tableView->showMaximized();
    5. tableView->setAlternatingRowColors(true);
    6.  
    7. //tableView->setHorizontalHeader(thermoNames);
    8. //tableView->setHorizontalHeaderLabels(QString(thermoNames));
    9.  
    10. tableView->resizeRowsToContents();
    11. tableView->resizeColumnsToContents();
    12. timeinterval.clear();
    13. tableView->verticalHeader()->setVisible(false);
    14. colNames.clear();
    To copy to clipboard, switch view to plain text mode 
    this is what i am doing to display all the channels data from the database table, but the header is the column names in the Table i wanted to display the header names which i have defines and stored in a QString thermoNames; , Pls help me out.

    Thank you
    Last edited by nagabathula; 10th August 2011 at 19:14.

Similar Threads

  1. Cannot see the header labels SQL
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 2
    Last Post: 27th June 2011, 01:38
  2. How to get user-defined message?
    By ponponfish in forum Qt Programming
    Replies: 3
    Last Post: 17th May 2011, 16:19
  3. Replies: 10
    Last Post: 6th April 2011, 10:05
  4. Using User Defined Libraries
    By csvivek in forum Qt Programming
    Replies: 1
    Last Post: 27th May 2008, 19:47
  5. User Defined Signal?
    By rajeshs in forum Newbie
    Replies: 2
    Last Post: 18th December 2007, 11:42

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
  •  
Qt is a trademark of The Qt Company.