gpt4 book ai didi

c++ - QCustomPlot include 在 Linux/Ubuntu 上导致奇怪的错误

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:13:11 25 4
gpt4 key购买 nike

只要我包含文件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。

提前致谢!

最佳答案

感谢您的帮助,我们找到了错误。事实上,它只是需要重新排序的一行。这是我们的 mainwindow.h:

#include <QMainWindow>
#include <QtWidgets>
#include "recognize.h"
#include "record.h"
#include "restrict.h"
#include "visualize.h"
#include "whitelist_dialog.h"
#include "qcustomplot/qcustomplot.h"

这是我们的 recognize.h:

#include <QtCore>
#include <QString>
#include <QWindow>
#include <QDebug>
#include <QDateTime>
#include <QCoreApplication>
#include "windowinfo.h"
#include "linux_x11.h"

这导致错误。我们所要做的就是重新排序我们 recognize.h 的包含,直到最后,就在

#include qcustomplot/qcustomplot.h

感谢您的帮助!永远记住,在 linux 下 includes 和 qcustomplot 的顺序很重要!

此外:讨论相同问题的链接: http://forum.qtfr.org/discussion/4438/qt4-linux-inclusion-de-xlib-h-qui-pose-probleme (不幸的是法语)

关于c++ - QCustomPlot include 在 Linux/Ubuntu 上导致奇怪的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34070802/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com