Important: Please read the Qt Code of Conduct -

Can't open a mysql-db on pi

  • I'm trying to open and access a mysql-db on a pi. I've built a cross development environment and it works fine.
    The problem now is this snippet:

    bool ret =;
    qDebug() << ret;
    qDebug() << "---------------------------";
    qDebug() << dbAbholer.lastError().text();
    qDebug() << "---------------------------";
    qDebug() << qApp->libraryPaths();
    qDebug() << QSqlDatabase::drivers();

    The output is:

    Unable to query physical screen size, defaulting to 100 dpi.
    To override, set QT_QPA_EGLFS_PHYSICAL_WIDTH and QT_QPA_EGLFS_PHYSICAL_HEIGHT (in millimeters).

    "Driver not loaded Driver not loaded"

    ("/usr/local/Qt-5.5.1-raspberry/plugins", "/home/pi")

    The access to the db should work, i've tried it via mysql-command line.

    Whats wrong with my code?

  • I tried a lot of things and find out the solution:

    QSqlDatabase dbAbholer;

    QSqlDatabase dbAbholer = QSqlDatabase::addDatabase("QMYSQL");

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    addDatabase is a static method that's why it didn't work. However, didn't you got a compiler warning when doing that ?

  • Thanks for your response. No i did not recognize any error while compiling.
    Well my development environment is: Windows PC with a virtual machine running ubuntu. The target is a raspberry. So its a cross-environment. Perhaps this is the reason?
    BTW, it tooks a very long time to build this environment with all drivers for sql, touch etc. Especially the touch in combination with eglfs was very hard (one need tslib from other sources etc.)

  • Lifetime Qt Champion

    Not an error, a warning.

    Embedded development is rarely a piece of cake ;)

Log in to reply