Tag Archives: Qt

[Solved] QT operate error: exited with code – 1073741515

The build environment qt5.9.5 + msvc2015 32bit is compiled successfully, and the following errors are generated during operation:

Starting ****.exe...
exited with code -1073741515

Cause of problem:

Due to the use of C + + third-party libraries such as boost and ODB, or third-party QML libraries such as toou2d, which are linked by dynamic link, an error is reported due to the lack of third-party libraries at runtime.

Solution:

1. First find the Qt library that the program depends on, including the QML Library: open the command line tool of the currently used build kit, such as: (MSCV 2015 (32bit))

Enter the running executable file * * *. Exe directory,

input   “windeployqt –qmldir C:\Qt\Qt5.9.5\5.9.5\msvc2015\qml .\ ”   , among  C:\QT\qt5.9.5\5.9.5\msvc2015\QM is the location of QT installation environment QML.

In this way, QT will automatically import all the dependent dynamic libraries to the location of the program.

In addition, if a third-party QML library is used, QT may not be automatically imported into the third-party library and needs to be imported manually. If I use toou2, I need to manually put the directory toou2d containing toou2d.dll into the current directory.

2. Add the third-party libraries one by one. If you don’t know what libraries are missing, you can run the program directly first. The program will fail to start and display the missing library files, such as:

After all dependent dynamic libraries are imported, they can be started normally.

It is best to run in a non build environment, because our build environment will add many environment variables. When the program cannot find the dependent Library in the current directory, it will find it in the directory of environment variables. All programs that are often debugged or can run normally on the compiling machine can not run on another computer.

[Solved] QT Error: error: undefined reference to ‘vtable for XXX’  

1. Description of problems encountered

An error occurred in a constructor during compilation:

1 error: undefined reference to ‘vtable for XXX’

2. Cause analysis

Cause of error: This usually occurs in a class that inherits QObject. It is usually a newly defined subclass that does not implement the pure virtual function of the parent class.

In QT, when you encounter this situation, you should first think of adding a new class inherited from QObject to a class and adding Q_ The macro object,

After that, this error will be reported whether it is built or rebuilt. The root cause is that only build and rebuild will be performed without compiling   Q_ Object macro (and no new MOC file will be generated),

Therefore, you need to execute qmake first and let the MOC compiler precompile Q_ Object macro. PS: you can execute qmake once before running the program

3. Solutions

Re-execute qmake and rebuild.

Generally, this problem is solved to avoid forgetting to take notes~

Qt Build Project Error: No rule to make target ‘TarWidget.cpp’, neede d by ‘TarWidget.o’. Stop.

Because I put tarwidget.cpp in the view folder, open the .Pro file:

SOURCES += TarWidget.cpp\

View/TarWidgdet.cpp\

There are two. Delete the upper one.

SOURCES += View/TarWidgdet.cpp\

It also needs to be deleted under headers.

Finally, just execute qmake.

QT Compilation error: invalid application of ‘sizeof’ to incomplete type ‘Qt3DRender::QPickEvent’

When you perform the pick operation on the entity in 3D, the result is a compilation error: invalid application of ‘sizeof’ to include type ‘qt3drender:: qpickevent’

Qt3DRender::QObjectPicker *picker = new Qt3DRender::QObjectPicker(m_ sphereEntity);
picker-> setHoverEnabled(true);
picker-> setEnabled(true);
connect(picker, & Qt3DRender::QObjectPicker::clicked, this, & SceneModifier::mouseClicked); // Error line

Slot function prototype: void mouseClick (qt3drender:: qpickevent * EVT)

Try to try to go, the result is that the header file does not contain, including the header file can

#include <QPickEvent>
The QPickEvent class holds information when an object is picked.
This is received as a parameter in most of the QObjectPicker component signals when picking succeeds.

Solving the problem of QT connecting MySQL database in Windows system: qmmysql driver not loaded

In the process of learning QT, we encountered the situation that we could not connect to the database

#include <QApplication>
#include <QtSql>
#include <QMessageBox>
#include <QDebug>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

 //Show existing database driver
    qDebug()<<QSqlDatabase::drivers();

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("localhost");
    db.setDatabaseName("dbname");
    db.setUserName("root");
    db.setPassword("password");
    
    if (!db.open()) {
       QMessageBox::critical(0, QObject::tr("Database Error"),
                              db.lastError().text());
    }

    return a.exec();
}

The output of the console is:

As shown above, MySQL driver exists, but it still prompts an error: qmmysql driver not loaded

The reason is that libmysql.dll is missing in the program

This dynamic connection library is in the Lib directory of the MySQL installation file. For example, if my MySQL is installed on Disk C, libmysql.dll is located at:

C:\MySQL\MySQL Server 5.7\lib\

Find libmysql.dll, copy it to the directory where your exe is located, and then run the program. At this time, you can connect to MySQL

note: 32-bit QT program must use 32-bit libmysql.dll, not 64 bit. Similarly, 64 bit programs use 64 bit libmysql. DLL

Libmysql.dll can be found in the Lib directory of the MySQL installation file

If there is no corresponding version, you can also download it here:

Connection: http://pan.baidu.com/s/1kVKwLuR

Password: v6uy

You can connect to the database through the above method, but it is very troublesome to copy libmysql.dll to the directory where the EXE is located every time. Therefore, when writing programs, you can use a convenient method:

Copy libmysql.dll to the bin directory of QT installation file, such as my bin directory:

D:\Qt\Qt5.7.0\5.7\mingw53_32\bin\

After copying to the bin directory, there is no need to copy libmysql.dll to the directory where the EXE is located. The program can connect to the MySQL database correctly

Qt qt.qpa.xcb: QXcbConnection: XCB error: 8 (BadMatch)…..

After QT is compiled, the running program will report the following error

17:46:32: Starting /home/wyl/Documents/Qtcode/RSViewer/RSViewer_build/RSViewer...
qt.qpa.xcb: QXcbConnection: XCB error: 8 (BadMatch), sequence: 770, resource id: 136314920, major code: 130 (Unknown), minor code: 3
qt.qpa.xcb: QXcbConnection: XCB error: 8 (BadMatch), sequence: 935, resource id: 136314920, major code: 130 (Unknown), minor code: 3
qt.qpa.xcb: QXcbConnection: XCB error: 8 (BadMatch), sequence: 1010, resource id: 136314920, major code: 130 (Unknown), minor code: 3
qt.qpa.xcb: QXcbConnection: XCB error: 8 (BadMatch), sequence: 1059, resource id: 136314920, major code: 130 (Unknown), minor code: 3
qt.qpa.xcb: QXcbConnection: XCB error: 8 (BadMatch), sequence: 1070, resource id: 136314920, major code: 130 (Unknown), minor code: 3
qt.qpa.xcb: QXcbConnection: XCB error: 8 (BadMatch), sequence: 1211, resource id: 136314982, major code: 130 (Unknown), minor code: 3
qt.qpa.xcb: QXcbConnection: XCB error: 8 (BadMatch), sequence: 1349, resource id: 136314996, major code: 130 (Unknown), minor code: 3
qt.qpa.xcb: QXcbConnection: XCB error: 8 (BadMatch), sequence: 1583, resource id: 136315025, major code: 130 (Unknown), minor code: 3
qt.qpa.xcb: QXcbConnection: XCB error: 8 (BadMatch), sequence: 1790, resource id: 136315025, major code: 130 (Unknown), minor code: 3
qt.qpa.xcb: QXcbConnection: XCB error: 8 (BadMatch), sequence: 1839, resource id: 136315025, major code: 130 (Unknown), minor code: 3
qt.qpa.xcb: QXcbConnection: XCB error: 8 (BadMatch), sequence: 1850, resource id: 136315025, major code: 130 (Unknown), minor code: 3
qt.qpa.xcb: QXcbConnection: XCB error: 8 (BadMatch), sequence: 1978, resource id: 136315074, major code: 130 (Unknown), minor code: 3
qt.qpa.xcb: QXcbConnection: XCB error: 8 (BadMatch), sequence: 2112, resource id: 136315088, major code: 130 (Unknown), minor code: 3
qt.qpa.xcb: QXcbConnection: XCB error: 8 (BadMatch), sequence: 2343, resource id: 136315113, major code: 130 (Unknown), minor code: 3
qt.qpa.xcb: QXcbConnection: XCB error: 8 (BadMatch), sequence: 2538, resource id: 136315113, major code: 130 (Unknown), minor code: 3
qt.qpa.xcb: QXcbConnection: XCB error: 8 (BadMatch), sequence: 2587, resource id: 136315113, major code: 130 (Unknown), minor code: 3
qt.qpa.xcb: QXcbConnection: XCB error: 8 (BadMatch), sequence: 2598, resource id: 136315113, major code: 130 (Unknown), minor code: 3
qt.qpa.xcb: QXcbConnection: XCB error: 8 (BadMatch), sequence: 2744, resource id: 136315164, major code: 130 (Unknown), minor code: 3
qt.qpa.xcb: QXcbConnection: XCB error: 8 (BadMatch), sequence: 2878, resource id: 136315178, major code: 130 (Unknown), minor code: 3

Why

QT could not find xcb dynamic library

Libqxcb library is not copied to the release package, or libqxcb needs incomplete dynamic libraries

Solutions

Install QT in qt5.6.3/5.6.3/gcc_ Copy 64/plugins/platforms to the directory where the QT program is located,
use LDD to check whether the library libqxcb needs to link can be found, if not, copy the missing library to the publishing package

This paper solves the problem that the program published by QT prompts “unable to locate the program input point k32getmodulefilenameexa on the dynamic link library Kernel32. DLL” in XP environment

When developing with QT, there is no big problem when calling system API function in win7 and above systems. In XP, the phenomenon of Title Description appears, which makes it impossible to start the program. The solutions on the Internet are as follows:

Here I want to discuss some unfriendly errors in WinSDK v7.0. If you are a developer and are currently using WinSDK v7.0, which is included in the VS2010 compiler, when you execute a program, you can, You may encounter such an error prompt: the procedure entry point k32 * * could not be located in the dynamic link library Kernel32. DLL
the Chinese version is: unable to locate the program input point k32enumprocessmodules on the dynamic link library Kernel32. DLL. This kind of error prompt usually appears on the system other than Windows 7 or Windows Server 2008 R2

next, I’ll explain why such mistakes occur. Because of some performance problems, on Windows 7 and Windows Server 2008 R2 systems, Microsoft moved some API functions from psapi.dll to kernel32.dll dynamic library, and dealt with them on the version v7.0 of WinSDK that comes with VS2010 compiler. This design has no problem in Windows 7 and Windows Server 2008 R2 systems, but if you run the program compiled by VS2010 on the system before win7, you will definitely encounter the error just mentioned. Because the old system’s kernel32.dll does not have those functions that have been transplanted in the past, it will certainly fail to execute

the affected functions are as follows:

//Snapshot from Psapi.lib – WinSDK V7.0*

#if (PSAPI_ VERSION > 1)

#define EnumProcesses K32EnumProcesses

#define EnumProcessModules K32EnumProcessModules

#define EnumProcessModulesEx K32EnumProcessModulesEx

#define GetModuleBaseNameA K32GetModuleBaseNameA

#define GetModuleBaseNameW K32GetModuleBaseNameW

#define GetModuleFileNameExA K32GetModuleFileNameExA

#define GetModuleFileNameExW K32GetModuleFileNameExW

#define GetModuleInformation K32GetModuleInformation

#define EmptyWorkingSet K32EmptyWorkingSet

#define QueryWorkingSet K32QueryWorkingSet

#define QueryWorkingSetEx K32QueryWorkingSetEx

#define InitializeProcessForWsWatch K32InitializeProcessForWsWatch

#define GetWsChanges K32GetWsChanges

#define GetWsChangesEx K32GetWsChangesEx

#define GetMappedFileNameW K32GetMappedFileNameW

#define GetMappedFileNameA K32GetMappedFileNameA

#define EnumDeviceDrivers K32EnumDeviceDrivers

#define GetDeviceDriverBaseNameA K32GetDeviceDriverBaseNameA

#define GetDeviceDriverBaseNameW K32GetDeviceDriverBaseNameW

#define GetDeviceDriverFileNameA K32GetDeviceDriverFileNameA

#define GetDeviceDriverFileNameW K32GetDeviceDriverFileNameW

#define GetProcessMemoryInfo K32GetProcessMemoryInfo

#define GetPerformanceInfo K32GetPerformanceInfo

#define EnumPageFilesW K32EnumPageFilesW

#define EnumPageFilesA K32EnumPageFilesA

#define GetProcessImageFileNameA K32GetProcessImageFileNameA

#define GetProcessImageFileNameW K32GetProcessImageFileNameW

#endif

Copy code

Through the above explanation, you should understand why there is such a mistake, right?In general, I know how to correct this mistake. I don’t know if you have noticed that there is a conditional judgment # if (psapi)_ VERSION > 1) That is to say, only when psapi_ Version is defined as a value greater than 1, so the solution is to use psapi_ Version is defined as a value less than or equal to 1, as follows:

To add “include & lt; Psapi.h> Above

#ifndef PSAPI_ VERSION
#define PSAPI_ VERSION 1
#endif

#include < Tlhelp32.h>
#include < Psapi.h>
#pragma comment(lib, “Psapi.lib”)

At this point, the problem can be solved. Pay attention to the red font part. At the beginning, only the upper part is added. Compile the exception directly, and add the red part of the next line. Just started to set foot in QT, encountered problems can be solved online, the problem listed for their own reference