Results 1 to 4 of 4

Thread: Qt4 - QSqlQueryModel x Qt3 QDataTable

  1. #1
    Join Date
    Sep 2006
    Location
    Rio de Janeiro, Brazil
    Posts
    44
    Thanks
    2
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11

    Default Qt4 - QSqlQueryModel x Qt3 QDataTable

    Hello Friends,

    I am porting my application that was in Qt3 for Qt4.

    Good, it would like to take off a doubt, I I used the QDataTable in the Qt3, now
    I am using the QTableView with the QSqlQueryModel.

    I had the following code before.

    =Qt3 part code===========================
    ...
    QString sql = QString("SQL OF 130 LINES").arg(idGlobal);

    QSqlSelectCursor *cur = new QSqlSelectCursor(sql);

    dataTable->addColumn("id_1", tr("Nº"), 70);
    dataTable->addColumn("id_2", tr("Test"), 30);
    ...
    =Qt3 end code============================

    Now in the Qt4 I am making thus:

    =Qt4 part code===========================
    ...
    QSqlQueryModel *model = new QSqlQueryModel(this->tableView);
    model->setQuery(QString("O SQL GRANDE").arg( globalIdentID ));

    model->setHeaderData(0, Qt::Horizontal, QObject::tr("Nº"))
    model->setHeaderData(0, Qt::Horizontal, QObject::tr("Nº"))
    ...
    =Qt4 end code============================

    This functions, more the doubt is, as I make to only bring fields that I desire, eat I I made before when I added the column in the QDataTable. Therefore this SQL returns a mount from thing, more I wants only determined fields, thus making it brings everything in the screen.

    Somebody knows as can make this?

    edm.

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

    Default Re: Qt4 - QSqlQueryModel x Qt3 QDataTable

    I'm not sure what you mean, but if you want to have only some of the columns of the model visible, you can either hide respective columns in the table view (which is a worse possibility) or apply a filter model on the original model that will filter out unwanted columns. Or you can change the SQL query so that it only contains the columns you want, but I guess you are aware of that.

  3. #3
    Join Date
    Sep 2006
    Location
    Rio de Janeiro, Brazil
    Posts
    44
    Thanks
    2
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Qt4 - QSqlQueryModel x Qt3 QDataTable

    Hi,

    I did not understand, As I can create this filter? Unhappyly consultation SQL cannot be modified.

    edm

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

    Default Re: Qt4 - QSqlQueryModel x Qt3 QDataTable

    Take a look at QSortFilterProxyModel class.

Similar Threads

  1. QSqlQueryModel data update
    By psi in forum Qt Programming
    Replies: 4
    Last Post: 20th July 2012, 04:59
  2. Rollback transactions in QDataTable
    By bubba in forum Qt Programming
    Replies: 0
    Last Post: 25th July 2007, 10:41
  3. QDataTable to bloquer modified value
    By cristiano in forum Qt Programming
    Replies: 5
    Last Post: 17th January 2007, 01:58
  4. Refresh QDataTable
    By shamik in forum Qt Programming
    Replies: 25
    Last Post: 1st December 2006, 06:04
  5. QSqlQueryModel + set Write
    By raphaelf in forum Qt Programming
    Replies: 7
    Last Post: 5th June 2006, 09:55

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.