Results 1 to 5 of 5

Thread: QT4 : need database/form/window sample

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QT4 : need database/form/window sample

    Probably the simplest example is something like this:


    Qt Code:
    1. #include <QApplication>
    2. #include <QSqlTableModel>
    3. #include <QTableView>
    4. #include <QSqlDatabase>
    5.  
    6. int main(int argc, char **argv){
    7. QApplication app(argc, argv);
    8. QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
    9. db.setHostName("acidalia");
    10. db.setDatabaseName("customdb");
    11. db.setUserName("mojito");
    12. db.setPassword("J0a1m8");
    13. bool ok = db.open();
    14. if(!ok) return 2;
    15. model.setTable("sometable");
    16. model.setEditStrategy(QSqlTableModel::OnRowChange);
    17. tv.setModel(&model);
    18. tv.show();
    19. return app.exec();
    20. }
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to wysota for this useful post:

    marvaneke (18th July 2006)

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.