Results 1 to 12 of 12

Thread: QSqlTableModel/QSqlQueryModel

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Posts
    115
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QSqlTableModel/QSqlQueryModel

    Hello everyone,

    I,am newbie,

    I have a MainWindow with several lineEdits calling: leMateriaal, leDin_norm etc..
    I have a searchDialog with comboboxen calling: materiaalComboBox, dinCombobox etc..
    I have a connection with a extern database with several rows of input.
    If i pop-up my searchDialog in the MainWindow en choose in the combox of the searchDialog the currentText() en push the button ok the seachDialog must be searching in the database for the chosen items en show them in the MainWindow lineEdits.
    The problem is i try several options but nothing works.

    The first option was QSqlTableModel:
    Qt Code:
    1. void MainWindow::search()
    2. {
    3. searchDialog dlg(this)
    4. QString mat = dlg.leMateriaalComboBox->currentText()
    5. QString din = dlg.leDinComboBox->currentText()
    6. if(dlg.exec() == QDialog::Accepted) {
    7.  
    8. QSqltableModel model;
    9. model.setTable("frezen");
    10. model.select();
    11. QString mat = model.record(1).value("Materiaal").toString();
    12. leMateriaal->setText(mat);
    13. QString din = model.record(1).value("Din_norm").toString();
    14. leDin->setText(din);
    15. }
    16. }
    To copy to clipboard, switch view to plain text mode 
    In the MainWindow i only see the first record not the the item i choose in my searchDialog combobox.
    My second option was the same with QSqlQueryModel.

    Is it possible when i choose items in the comboboxen in the searchDialog then searchDialog searching in the database en put the items in my MainWindow lineEdits.
    Is something missing in my code?
    Last edited by jacek; 10th December 2006 at 19:55. Reason: changed [html] to [code]

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.