编译时未实现的 QColor 错误 (C++)

Unimplemented QColor error on compliation (C++)

本文关键字:错误 C++ QColor 实现 编译      更新时间:2023-10-16

我正在遵循Qt的Qt初学者教程,由于某种原因,我在尝试构建最简单的gui示例时遇到编译错误。看起来它在按钮创建时失败了,因为它认为 qcolor 未实现(?我刚刚下载了最新的Qt 5.14.0并今天安装了它,所以安装过程中可能发生了什么?

这是我的项目布局的样子:

build-new_qt_project-Desktop_Qt_5_14_0_GCC_64bit-Debug:
Makefile
new_qt_project:
main.cpp
new_qt_project.pro

主.cpp:

#include <QApplication>
#include <QPushButton>
int main(int argc, char **argv)
{
QApplication app (argc, argv);
QPushButton button ("Hello world !");
button.show();
return app.exec();
}

new_qt_project.pro:

TEMPLATE = app
TARGET = new_qt_project
QT = core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
SOURCES += main.cpp

这是尝试制作它的输出:

In file included from ../../Qt5.14.0_2/5.14.0/gcc_64/include/QtGui/qpixmap.h:45:0,
from ../../Qt5.14.0_2/5.14.0/gcc_64/include/QtGui/qicon.h:46,
from ../../Qt5.14.0_2/5.14.0/gcc_64/include/QtWidgets/qabstractbutton.h:44,
from ../../Qt5.14.0_2/5.14.0/gcc_64/include/QtWidgets/qpushbutton.h:44,
from ../../Qt5.14.0_2/5.14.0/gcc_64/include/QtWidgets/QPushButton:1,
from ../new_qt_project/main.cpp:2:
../../Qt5.14.0_2/5.14.0/gcc_64/include/QtGui/qcolor.h: In constructor ‘constexpr QColor::QColor(int, int, int, int)’:
../../Qt5.14.0_2/5.14.0/gcc_64/include/QtGui/qcolor.h:79:18: sorry, unimplemented: use of the value of the object being constructed in a constant expression
0) {}
^
make: *** [main.o] Error 1

我正在使用默认(检测到的(工具包来构建它,并且它的C++编译器指向/usr/bin 中的编译器,所以我认为这是正确的。我错过了什么吗?

我认为这就是问题所在:

Qt错误

更新您的 gcc. 最多 4.9 !!

我遇到了这个问题,我使用了 GCC 4.8,将其更新到 GCC-7 后现在是正确的