gpt4 book ai didi

c++ - 移动到Qt5 : 'Type' has not been declared 时出现编译错误

转载 作者:行者123 更新时间:2023-11-30 00:51:20 26 4
gpt4 key购买 nike

使用 Qt 5.2.1 编译旧的 Qt Project(可能由 Qt 4.8 创建):Lan Messenger 开源:

#ifndef QTSINGLEAPPLICATION_H
#define QTSINGLEAPPLICATION_H

#include <QApplication>

class QtLocalPeer;

#if defined(Q_WS_WIN) || defined(Q_OS_WIN32)
# if !defined(QT_QTSINGLEAPPLICATION_EXPORT) && !defined(QT_QTSINGLEAPPLICATION_IMPORT)
# define QT_QTSINGLEAPPLICATION_EXPORT
# elif defined(QT_QTSINGLEAPPLICATION_IMPORT)
# if defined(QT_QTSINGLEAPPLICATION_EXPORT)
# undef QT_QTSINGLEAPPLICATION_EXPORT
# endif
# define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllimport)
# elif defined(QT_QTSINGLEAPPLICATION_EXPORT)
# undef QT_QTSINGLEAPPLICATION_EXPORT
# define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllexport)
# endif
#else
# define QT_QTSINGLEAPPLICATION_EXPORT
#endif

class QT_QTSINGLEAPPLICATION_EXPORT QtSingleApplication : public QApplication
{ Q_OBJECT

public:
QtSingleApplication(int &argc, char **argv, bool GUIenabled = true);
QtSingleApplication(const QString &id, int &argc, char **argv);
QtSingleApplication(int &argc, char **argv, Type type);
#if defined(Q_WS_X11)
QtSingleApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0);
QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0);
QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0);
#endif

bool isRunning();
QString id() const;

void setActivationWindow(QWidget* aw, bool activateOnMessage = true);
QWidget* activationWindow() const;

// Obsolete:
void initialize(bool dummy = true)
{ isRunning(); Q_UNUSED(dummy) }

public Q_SLOTS:
bool sendMessage(const QString &message, int timeout = 5000);
void activateWindow();


Q_SIGNALS:
void messageReceived(const QString &message);


private:
void sysInit(const QString &appId = QString());
QtLocalPeer *peer;
QWidget *actWin;
};

#endif // QTSINGLEAPPLICATION_H

错误:“类型”尚未声明

我不知道如何修复这些错误。有人会帮忙吗?谢谢。

最佳答案

引用自 Qt 存储库中的提交:

QCoreApplication::Type and QApplication::type() have been removed. These Qt3 legacy application types did not match the application types available in Qt5. Use for example qobject_cast instead to dynamically find out the exact application type.

https://qt.gitorious.org/qt/qtbase/commit/553e216d891177ee0c2cea70bbd7f21103fc7795 .

作为解决方法,如果您没有在 QtSingleApplication 构造函数中指定类型,那么您可以将其注释掉并在没有它的情况下继续使用 QtSingleApplication。

qtsingleapplication.h:第 70 行:

//QtSingleApplication(int &argc, char **argv, Type type);

qtsingleapplication.cpp:第 176 行:

/*QtSingleApplication::QtSingleApplication(int &argc, char **argv, Type type) : 
QApplication(argc, argv, type)
{
sysInit();
}*/

关于c++ - 移动到Qt5 : 'Type' has not been declared 时出现编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22294737/

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