How to patch 'QSqlDatabase::open always returns true with QMYSQL'



  • Hi, I'am currently developing an application using Clion as IDE which uses CMake to build the project. For my project I will need to use a MySQL db using Qt5 libraries. Earlier I found that a bug affects QSqlDatabase when using the QMYSQL driver. Also found that is already patched in version 5.5.1, however the package provided by my Os (ArchLinux) is version 5.5.0

    How can I apply the 5.5.1 patch so that my current CMakeLists.txt keep it running.
    If that isn't possible, how can I make CMake or Clion to look up all the qt5 libraries in the directory that Qt5 installer created?

    Thanks in advance.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You can either clone the qtbase sources and checkout the 5.5.1 branch or get the patch here and apply it to your sources



  • Hello Mr. Gaist thank you for the response.
    I went through the first option, after following every step in this guide still cannot make QSqlDatabase to work. I assume CMake still seeks for Qt libraries at /usr/include|/usr/lib and not into /usr/local/Qt-5.5.1
    Do I have to change anything else in order to make it work. I tried to uninstall qt5-base package with no success because it is a dependency of another packages.

    Edit:

    [ricardo@ricardo-desktop ~]$ whereis qmake
    qmake: /usr/bin/qmake /usr/local/Qt-5.5.1/bin/qmake
    

  • Lifetime Qt Champion

    Are you using CMake or qmake for your application ? If the former then you need to tell CMake where to look for Qt. CMake doesn't use qmake at all.



  • I am using CMake. The qmake example was to show that Qt 5.5.1 is installed but also Qt 5.5.0 is and CMake keeps choosing the latter.

    Can you point how to tell CMake to look for Qt in the right directory?
    I was trying to follow the official documentation and specifically this step which I think is the one I need in order to tell CMake where to look

    find_package(Qt5Core)
    
    get_target_property(QtCore_location Qt5::Core LOCATION)
    

    However, I can't figure out what LOCATION means or how could I replace the right path there and I haven't found anything useful in google so far. I followed this link where LOCATION property is explained but I still cannot figure it out. Note that I am kinda newbie using CMake and Qt.


  • Lifetime Qt Champion

    You can add the minimum version of Qt you want if cmake does find several versions



  • Thank you very much. Today, the Qt version 5.5.1 was pushed to the official ArchLinux's repositories. The problem is gone.


  • Lifetime Qt Champion

    You're welcome !

    Since everything is working now, please mark the thread as solved so other forum users may know a solution has been found :)



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