[Solved]QString, QSqlQueryModel ("message + QString") how?



  • So I want to do a search in a database. I have a QLineEdit, I get the value from there (value is something like: nokia) then I want to do this:
    @QSqlQuerryModel qry;
    QString string = ui->LineEdit->text();
    qry->setQuerry("Select something1, something2 from aTable where something like '(qstring that is nokia)');
    @

    I tried with :string and it doesn't work.
    How can I append the string to the message but wrapped with ' ' ?



  • @qry->setQuery("Select '" + string + "' from aTable");@

    give that a try.

    or
    @QString helpString = "Select '" + string + "' from aTable";
    qry->setQuery(helpString);
    @



  • It worked. Thank you very much.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.