$main.cpp:5: error: C1083: 无法打开包括文件: “QState”: No such file or directory
include<QStateMachine>时候也是这个问题,目前Qt版本应该是6
.pro文件中是这样:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
main.cpp是这样:
#include "mainwindow.h"
#include <QApplication>
#include <QPushButton>
#include <QState>
#include <QStateMachine>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QPushButton button("State Machine");
QStateMachine machine;
QState* s1 = new QState(&machine);
return a.exec();
}
|