Important: Please read the Qt Code of Conduct -

[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.

    @QString helpString = "Select '" + string + "' from aTable";

  • It worked. Thank you very much.

Log in to reply