每当我只包含文件qcustomplot.h
时,就会出现大量错误。我似乎无法解决这个问题,特别是因为它在 Windows 和 Mac 上运行良好。也许有人遇到过同样的问题。
以下是出现的错误消息:
In file included from ../maitime/linux_x11.h:9:0,
from ../maitime/recognize.h:20,
from ../maitime/mainwindow.h:6,
from ../maitime/main.cpp:2:
../../../Qt/5.5/gcc_64/include/QtPrintSupport/qabstractprintdialog.h:64:9: error: expected identifier before numeric constant
None = 0x0000, // obsolete
^
../../../Qt/5.5/gcc_64/include/QtPrintSupport/qabstractprintdialog.h:64:9: error: expected '}' before numeric constant
../../../Qt/5.5/gcc_64/include/QtPrintSupport/qabstractprintdialog.h:64:9: error: expected unqualified-id before numeric constant
In file included from ../../../Qt/5.5/gcc_64/include/QtCore/qglobal.h:1102:0,
from ../../../Qt/5.5/gcc_64/include/QtCore/qcoreapplication.h:37,
from ../../../Qt/5.5/gcc_64/include/QtWidgets/qapplication.h:37,
from ../../../Qt/5.5/gcc_64/include/QtWidgets/QApplication:1,
from ../maitime/main.cpp:1:
../../../Qt/5.5/gcc_64/include/QtPrintSupport/qabstractprintdialog.h:74:41: error: 'PrintDialogOption' was not declared in this scope
Q_DECLARE_FLAGS(PrintDialogOptions, PrintDialogOption)
^
../../../Qt/5.5/gcc_64/include/QtCore/qflags.h:156:16: note: in definition of macro 'Q_DECLARE_FLAGS'
typedef QFlags<Enum> Flags;
^
../../../Qt/5.5/gcc_64/include/QtCore/qflags.h:156:20: error: template argument 1 is invalid
typedef QFlags<Enum> Flags;
^
../../../Qt/5.5/gcc_64/include/QtPrintSupport/qabstractprintdialog.h:74:5: note: in expansion of macro 'Q_DECLARE_FLAGS'
Q_DECLARE_FLAGS(PrintDialogOptions, PrintDialogOption)
^
In file included from ../../../Qt/5.5/gcc_64/include/QtPrintSupport/QtPrintSupport:4:0,
from ../maitime/qcustomplot/qcustomplot.h:54,
from ../maitime/mainwindow.h:11,
from ../maitime/main.cpp:2:
../../../Qt/5.5/gcc_64/include/QtPrintSupport/qabstractprintdialog.h:77:44: error: expected ')' before '*' token
explicit QAbstractPrintDialog(QPrinter *printer, QWidget *parent = 0);
^
../../../Qt/5.5/gcc_64/include/QtPrintSupport/qabstractprintdialog.h:78:28: error: expected constructor, destructor, or type conversion before ';' token
~QAbstractPrintDialog();
^
../../../Qt/5.5/gcc_64/include/QtPrintSupport/qabstractprintdialog.h:80:22: error: 'virtual' outside class declaration
virtual int exec() = 0;
^
../../../Qt/5.5/gcc_64/include/QtPrintSupport/qabstractprintdialog.h:80:26: error: function 'int exec()' is initialized like a variable
virtual int exec() = 0;
^
../../../Qt/5.5/gcc_64/include/QtPrintSupport/qabstractprintdialog.h:83:27: error: variable or field 'addEnabledOption' declared void
void addEnabledOption(PrintDialogOption option);
^
../../../Qt/5.5/gcc_64/include/QtPrintSupport/qabstractprintdialog.h:83:27: error: 'PrintDialogOption' was not declared in this scope
../../../Qt/5.5/gcc_64/include/QtPrintSupport/qabstractprintdialog.h:85:41: error: non-member function 'PrintDialogOptions enabledOptions()' cannot have cv-qualifier
PrintDialogOptions enabledOptions() const;
^
../../../Qt/5.5/gcc_64/include/QtPrintSupport/qabstractprintdialog.h:86:26: error: 'PrintDialogOption' was not declared in this scope
bool isOptionEnabled(PrintDialogOption option) const;
^
../../../Qt/5.5/gcc_64/include/QtPrintSupport/qabstractprintdialog.h:86:52: error: expected ',' or ';' before 'const'
bool isOptionEnabled(PrintDialogOption option) const;
^
../../../Qt/5.5/gcc_64/include/QtPrintSupport/qabstractprintdialog.h:90:24: error: variable or field 'setPrintRange' declared void
void setPrintRange(PrintRange range);
^
../../../Qt/5.5/gcc_64/include/QtPrintSupport/qabstractprintdialog.h:90:24: error: 'PrintRange' was not declared in this scope
../../../Qt/5.5/gcc_64/include/QtPrintSupport/qabstractprintdialog.h:91:5: error: 'PrintRange' does not name a type
PrintRange printRange() const;
^
../../../Qt/5.5/gcc_64/include/QtPrintSupport/qabstractprintdialog.h:94:19: error: non-member function 'int minPage()' cannot have cv-qualifier
int minPage() const;
^
../../../Qt/5.5/gcc_64/include/QtPrintSupport/qabstractprintdialog.h:95:19: error: non-member function 'int maxPage()' cannot have cv-qualifier
int maxPage() const;
^
../../../Qt/5.5/gcc_64/include/QtPrintSupport/qabstractprintdialog.h:98:20: error: non-member function 'int fromPage()' cannot have cv-qualifier
int fromPage() const;
^
../../../Qt/5.5/gcc_64/include/QtPrintSupport/qabstractprintdialog.h:99:18: error: non-member function 'int toPage()' cannot have cv-qualifier
int toPage() const;
^
../../../Qt/5.5/gcc_64/include/QtPrintSupport/qabstractprintdialog.h:101:25: error: non-member function 'QPrinter* printer()' cannot have cv-qualifier
QPrinter *printer() const;
^
../../../Qt/5.5/gcc_64/include/QtPrintSupport/qabstractprintdialog.h:103:1: error: expected unqualified-id before 'protected'
protected:
^
../../../Qt/5.5/gcc_64/include/QtPrintSupport/qabstractprintdialog.h:106:1: error: expected unqualified-id before 'private'
private:
^
In file included from ../../../Qt/5.5/gcc_64/include/QtCore/qcoreapplication.h:37:0,
from ../../../Qt/5.5/gcc_64/include/QtWidgets/qapplication.h:37,
from ../../../Qt/5.5/gcc_64/include/QtWidgets/QApplication:1,
from ../maitime/main.cpp:1:
../../../Qt/5.5/gcc_64/include/QtCore/qglobal.h:1043:35: error: 'QAbstractPrintDialog& operator=(const QAbstractPrintDialog&)' must be a nonstatic member function
Class &operator=(const Class &) Q_DECL_EQ_DELETE;
^
../../../Qt/5.5/gcc_64/include/QtPrintSupport/qabstractprintdialog.h:107:5: note: in expansion of macro 'Q_DISABLE_COPY'
Q_DISABLE_COPY(QAbstractPrintDialog)
^
In file included from ../../../Qt/5.5/gcc_64/include/QtPrintSupport/QtPrintSupport:4:0,
from ../maitime/qcustomplot/qcustomplot.h:54,
from ../maitime/mainwindow.h:11,
from ../maitime/main.cpp:2:
../../../Qt/5.5/gcc_64/include/QtPrintSupport/qabstractprintdialog.h:110:1: error: expected declaration before '}' token
};
^
这是我的 .pro:
#-------------------------------------------------
#
# Project created by QtCreator 2012-05-09T21:19:57
#
#-------------------------------------------------
QT += core gui \
printsupport
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = maiTime
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
applicationdata.cpp \
visualize.cpp \
windowinfo.cpp \
record.cpp \
recognize.cpp \
restrict.cpp \
whitelist_dialog.cpp \
settings.cpp \
qcustomplot/qcustomplot.cpp
HEADERS += mainwindow.h \
windowinfo.h \
applicationdata.h \
visualize.h \
record.h \
recognize.h \
restrict.h \
whitelist_dialog.h \
settings.h \
qcustomplot/qcustomplot.h
macx {
OBJECTIVE_SOURCES += mac.mm
HEADERS += mac.h
LIBS += -framework Cocoa
}
unix:!macx {
HEADERS += linux_x11.h
SOURCES += linux_x11.cpp
LIBS += -lX11
CONFIG += c++11
}
win32 {
SOURCES += win.cpp
HEADERS += win.h
LIBS += -lpsapi
}
FORMS += \
mainwindow.ui \
whitelist_dialog.ui
RESOURCES += \
resources.qrc
ICON = lemon.icns
在创建一个全新的应用程序时,不会出现这些错误。这是我们如何包含文件的方式:(
#include "qcustomplot/qcustomplot.h"
是的,路径是正确的)
我们正在运行 Qt 5.5。
提前致谢!