1 Attachment(s)
from sqlquery to qstringlist
try to read a sqlquery, save it into a qstringlist and set it to combobox.
pass compile but combobox is empty.
Code:
query.prepare("SELECT lastname FROM employeestuf");
query.exec();
while(query.next())
{
if (query.isValid())
cblist<<query.value(0).toString();
}
ui->comboBox->addItems(cblist);
Re: from sqlquery to qstringlist
The errors are obvious in your posted code... you should learn to use the tools you already have to find it. Have you single stepped through the code in your debugger? Have you checked the error returns from QSqlQuery::exec() and QSqlQuery::lastError()? Have you looked at the database that is actually created? What tables exist? What tables are you trying to use in your code?
Re: from sqlquery to qstringlist
Hi all,
I am facing similar problem.
I have create the application using forms (ui file) using qtcreator.
when i try to add a list to the combo-box, its added but not displaying.
I have cross verified for the existance of the entries in the combo-box with count() and displays the
correct count i inserted and also it gives the correct values which fetched and displayed on terminal.
Can any one help me out with a method to display the same list in the application.
Thanks,
Uday Pratap
Re: from sqlquery to qstringlist
Code:
while(query->next())
{
combobox.addItem(query->value(0).toString());
}
Re: from sqlquery to qstringlist
Why on earth did you post that?
Not only is it wrong on many levels, it is what the original poster already had without any of the bad things.
Cheers,
_