Results 1 to 5 of 5

Thread: Row number in a QSqlQueryModel

  1. #1
    Join Date
    Jul 2006
    Location
    Atlanta, GA
    Posts
    86
    Thanks
    26
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Row number in a QSqlQueryModel

    Is there any way to remove the row number in a QSqlQueryModel? I tried:
    Qt Code:
    1. tableViewModel->removeColumn(0);
    To copy to clipboard, switch view to plain text mode 
    but that removes my first column of data.

    The reason I need this removed is the database missing the number 13 and seeing a row number next to the UID gets a little confusing. (I am a little superstitous.)
    fnmblot
    --------------------------------------
    Gee Ricky, I'm sorry your mom blew up.

  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: Row number in a QSqlQueryModel

    You mean the vertical header?
    Qt Code:
    1. tableView->verticalHeader()->hide();
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. #3
    Join Date
    Jul 2006
    Location
    Atlanta, GA
    Posts
    86
    Thanks
    26
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Row number in a QSqlQueryModel

    well, I am getting errors compiling when I try that method.

    src/tableVCS.cpp:22: error: invalid use of undefined type struct QHeaderView
    /usr/include/QtGui/qtableview.h:55: error: forward declaration of struct QHeaderView
    make[1]: *** [build/tableVCS.o] Error 1

    Here is the code for the table:
    Qt Code:
    1. #include "tableVCS.h"
    2. #include <QtSql>
    3. //
    4. tableVCSDlg::tableVCSDlg( QWidget * parent, Qt::WFlags f)
    5. : QDialog(parent, f)
    6. {
    7. tableVCSUi.setupUi(this);
    8.  
    9. QSqlQueryModel *tableViewModel = new QSqlQueryModel;
    10. tableViewModel->setQuery("SELECT piece_name, nn, short_instrum FROM main WHERE nn !='0' ORDER BY nn");
    11.  
    12. tableViewModel->setHeaderData(0, Qt::Horizontal, "Piece Name");
    13. tableViewModel->setHeaderData(1, Qt::Horizontal, "NN");
    14. tableViewModel->setHeaderData(2, Qt::Horizontal, "Instrumentation");
    15.  
    16.  
    17. tableVCSUi.tableView->setModel(tableViewModel);
    18. tableVCSUi.tableView->resizeColumnsToContents();
    19. tableVCSUi.tableView->verticalHeader()->hide();
    20. }
    21.  
    22. tableVCSDlg::~tableVCSDlg()
    23. {}
    24. //End tableVCS.cpp
    To copy to clipboard, switch view to plain text mode 
    fnmblot
    --------------------------------------
    Gee Ricky, I'm sorry your mom blew up.

  4. #4
    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: Row number in a QSqlQueryModel

    Qt Code:
    1. #include <QHeaderView>
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  5. The following user says thank you to jpn for this useful post:

    fnmblot (15th May 2008)

  6. #5
    Join Date
    Jul 2006
    Location
    Atlanta, GA
    Posts
    86
    Thanks
    26
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Talking Re: Row number in a QSqlQueryModel

    That is why you are a Guru and I am just a wee Novice. Thanks a million jpn! It worked like a charm.
    fnmblot
    --------------------------------------
    Gee Ricky, I'm sorry your mom blew up.

Similar Threads

  1. QSqlQueryModel speed problem
    By tbscope in forum Qt Programming
    Replies: 2
    Last Post: 23rd March 2008, 11:31
  2. Line Number - QTextEdit...???
    By deepusrp in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2007, 16:34
  3. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  4. get error number from qsqldatabase
    By mandal in forum Qt Programming
    Replies: 1
    Last Post: 19th January 2007, 10:20
  5. Replies: 6
    Last Post: 5th March 2006, 21:05

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.