Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved]QString, QSqlQueryModel ("message + QString") how?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    ogrishmania
    wrote on last edited by
    #1

    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 ' ' ?

    1 Reply Last reply
    0
    • B Offline
      B Offline
      b1gsnak3
      wrote on last edited by
      #2

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

      give that a try.

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

      1 Reply Last reply
      0
      • O Offline
        O Offline
        ogrishmania
        wrote on last edited by
        #3

        It worked. Thank you very much.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved