Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>this question is very shallow, but i will try to provide some ressources as this shows up pretty on top on many searches.</p> <p>First of all, you will have to compile the MYSQL driver for the QtCreator for your operating system.</p> <p>For Windows, check </p> <p><a href="https://stackoverflow.com/questions/1530282/qt-mysql-connectivity-using-windows-xp-qt-creator-4-5-2windows-32-bit">QT MySql connectivity using Windows XP, Qt Creator 4.5.2(windows 32 bit)</a></p> <p>Instructions for MacOS (and probably Linux) can be found here</p> <p><a href="http://www.qtcentre.org/threads/45296-QSqlDatabase-QMYSQL-driver-not-loaded" rel="nofollow noreferrer">http://www.qtcentre.org/threads/45296-QSqlDatabase-QMYSQL-driver-not-loaded</a></p> <p>Once your qt install includes the mysql driver, you can use the database with the (QSqlDatabase)(developer.qt.nokia.com/doc/qsqldatabase.html) class. Copying from <a href="http://cartan.cas.suffolk.edu/oopdocbook/html/qmysqldatabase.html" rel="nofollow noreferrer">here</a>:</p> <pre><code>QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); db.setHostName("localhost"); db.setDatabaseName("mysql"); db.setUserName("root"); db.setPassword("rootPW"); if (!db.open()) qDebug() &lt;&lt; "Failed to connect to root mysql admin"; </code></pre> <p>After that, you can use QSqlQuery to work with the database handle, e.g.</p> <pre><code>QSqlQuery query("SELECT * FROM mysql",db); </code></pre> <p>and print the results like</p> <pre><code>while (query.next()) { qDebug() &lt;&lt; "first column:" &lt;&lt; query.value(0).toString(); } </code></pre> <p>Code is not tested, but the Qt Documentation should clarify all details</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload