Results 1 to 6 of 6

Thread: QSqlQuery problem

Threaded View

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

    Default QSqlQuery problem

    Hello anyone,

    Iám newbe,

    I have a mainWindow with a lineEdit called leFirst.
    Ihave also a dialog called searchDialog with one combobox with 4 different names.(items)
    When i call the dialog in my MainWindow en select one item on the combobox i want that item been search in my database and put the result to my lineEdit in my MainWindow.
    code snippet:
    Qt Code:
    1. void MainWindow::search()
    2. {
    3. searchDialog dlg(this);
    4. if( dlg.exec() == QDialog::Accepted) {
    5.  
    6. QSqlQuery query("SELECT firstname FROM person");
    7. QString name = dlg.nameComboBox->currentText();
    8. if ( query.next() )
    9. name = (query.value(0).toString());
    10. leFirst->setText( name);
    11. }
    12. }
    To copy to clipboard, switch view to plain text mode 

    This works fine only for the first name in the combobox and showing up in the lineEdit.
    When i choose for the second name in the combobox ( the second item) then in lineEdit only shows the first name again and not the second name.
    Is something wrong in my code or missing something.
    I have tried severall options but nothing works.

    Thanks in advance.
    Last edited by wysota; 21st December 2006 at 22:46. Reason: reformatted to look better

Similar Threads

  1. QTimer problem ... it runs but never triggs
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 13:54
  2. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 13:45
  3. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 15:08
  4. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 22:36
  5. Replies: 16
    Last Post: 7th March 2006, 16:57

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.