What should I do if the UI interface displayed when Qt is run in Clion using CMake looks very old and outdated? How does Qt under CMake use SQLite?
Section 1: Problem Overview
If you compile the UI interface using the default configuration in CLion, it may appear outdated, resembling the Windows 2000 interface. However, if you run it using Qt Creator, there are no issues, and it looks like a modern Windows interface.
Section 2: Problem Cause
After some searching, I found a similar issue on StackOverflow. However, I provide a better solution here.
Including other modules like SQLite will result in DLL driver loading errors, such as “QSqlDatabase: QSQLITE driver not loaded.” This problem is related to the files in the cmake-build-debug directory not being copied to the plugins directory under MinGW in Qt.
To resolve this, simply copy the contents of D:\Qt\Qt5.14.2\5.14.2\mingw73_64\plugins to the cmake-build-debug directory.
However, this is not a permanent solution, as you will still need to configure it manually after rebuilding the project.
Section 3: Solution
In the CMakeLists.txt file, at the end of the if (WIN32) statement, add the following two lines:
1 | add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD |
Now, when you rebuild the project and run it, it will automatically check whether the corresponding plugins exist.