【发布时间】:2018-02-23 07:41:18
【问题描述】:
我对 Qt 比较陌生,并且正在阅读许多教程。一切都很好。所有脚本编译并运行。 然后,在某些时候,即使是使用 Qt Creator 4.3.1 创建的新 Qt 小部件应用程序,我也会收到错误消息:
C:\ \Documents\111\main.cpp:-1: In function 'int qMain(int, char**)':
C:\ \Documents\111\main.cpp:6: error: variable 'QApplication a' has initializer but incomplete type
QApplication a(argc, argv);
^
C:\ \Documents\111\main.cpp:11: warning: control reaches end of non-void function [-Wreturn-type]
}
^
我不确定发生了什么,但似乎有些设置搞砸了。
QApplication 包含在内,并且不会在脚本中丢失。
111.pro
# Project created by QtCreator 2018-02-23T01:36:28
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = 111
TEMPLATE = app
DEFINES += QT_DEPRECATED_WARNINGS
#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
main.cpp
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
mainview.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
在我看来,这个问题是在尝试从 https://en.ids-imaging.com/open-source.html 运行 qt5.6_src.zip 示例后出现的。
【问题讨论】:
-
首先,请拨打tour。其次,显示导致错误信息的代码;不要转储整个项目,而是将其设为minimal reproducible example,包括
.pro文件。 -
@NikosC。你认为这有什么不同吗?为什么?
标签: qt qt-creator qt-designer