Results 1 to 5 of 5

Thread: select estimate comboBox,date et time

  1. #1
    Join Date
    Mar 2014
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11

    Unhappy select estimate comboBox,date et time

    Hello, I want selects the contents of a ComboBox, and DateEdit TimeEdit
    This did not work
    it displays only the mat field

    Qt Code:
    1. QSqlQuery qry;
    2. qry.prepare("select * from Etudiant");
    3. if(qry.exec()){
    4. while(qry.next()){
    5. ui->lineEdit_matE->setText(qry.value(0).toString());
    6. ui->comboBox_sexE->setCurrentIndex(qry.value(1).toInt());
    7. ui->dateEdit_dateA->setDate(qry.value(2).toDate());
    8. ui->timeEdit_heureA->setTime(qry.value(3).toTime());
    9. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: select estimate comboBox,date et time

    What would you like us to do about it? What have you tried to do about it?

    Does the table contain four columns?
    Does the second column contain an integer? Does that integer match an entry in the combobox?
    Does the third column contain something that can be converted to a date?
    Does the fourth column contain something that can be converted to a date?

  3. #3
    Join Date
    Mar 2014
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: select estimate comboBox,date et time

    I want to retrieve the data of database to display it in my interface

    I have a problem with this code the following data: sex, date and time
    will not display in ComboBox, and dateEdit timeEdit

    What should I do

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: select estimate comboBox,date et time

    You could start by answering the questions.

  5. #5
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: select estimate comboBox,date et time

    First of all SQL query like "SELECT * FROM name_of_table" does not guarantee the order of columns in a reply. You must explicitly specify the columns in the query or the take values ​​by name instead of index.

Similar Threads

  1. Select multiple items in a combobox
    By sousadaniel7 in forum Qt Programming
    Replies: 11
    Last Post: 3rd May 2012, 13:57
  2. Replies: 1
    Last Post: 14th June 2011, 17:36
  3. Date Time
    By javed_alam786 in forum Qt Programming
    Replies: 2
    Last Post: 11th May 2011, 14:52
  4. How to estimate painting time?
    By 1111 in forum Qt Programming
    Replies: 1
    Last Post: 3rd March 2009, 21:24
  5. How to get a Multi select combobox
    By calmspeaker in forum Qt Programming
    Replies: 9
    Last Post: 26th August 2008, 05:49

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.