How send result query database to List<QString> ???
How send result query database to List<QString> ???
You will have to add more information on what you are trying to do.
What kind of values are you querying for? Does it query for one or more values per row?
Cheers,
_
I would like send value from two column table Qtableview (value int and varchar) to Qcombobox
query: select kod_lekarstwa, nazwa from lekarstwo;
I think about such loop:
for (list<QString>::iterator it=diseases.begin(); it != diseases.end(); ++it)
{
ui->diseasecomboBox->addItem(*it);
}
You can use QString::number() to convert the int value to a string and then use the + operator to concatenate with the second part.
That string can then easily be appended to a QStringList (which is a QList<QString>)
Cheers,
_
on start we try to do on the one column , only String values
select nazwa from lekarstwo;
it works, but I don't know how appended result query to QList
Qt Code:
QList<QString> list; list << "item1" << "item2" << "item3"; QString s; foreach( s, list ) { qDebug() << s; ui->comboBoxmedicine->addItem(s); }To copy to clipboard, switch view to plain text mode
Last edited by bartes19; 10th January 2016 at 12:19.
I am afraid I don't understand.
Your code already adds strings to the list, i.e. you already know how the << operator works.
Cheers,
_
Something like that?
list << query.exec("select kod_lekarstwa, nazwa from lekarstwo;");
exec() returns a bool.
You want to loop over the results. See the example in the documentation for QSqlQuery.
Cheers,
_
Bookmarks