本文介绍了移动到Qt5时的编译错误:“类型”尚未声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用Qt 5.2.1编译旧的Qt项目(可能由Qt 4.8创建):
Lan messenger开源:
Use Qt 5.2.1 to compile old Qt Project (maybe created by Qt 4.8):Lan messenger open source:
#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
错误:'类型'已声明
我不知道如何修复这些错误。
任何人会帮助吗?
谢谢。
I dont know how to fix these error.Will anyone help?Thank you.
推荐答案
从Qt仓库中的commit中引用:
Quote from commit in Qt repository :
。
作为一个解决方法,如果你没有在你的QtSingleApplication构造函数中指定类型,那么你可以注释掉它,仍然继续使用QtSingleApplication没有它。
As a workaround if you don't specify the type in your QtSingleApplication constructor then you can comment it out and still keep using QtSingleApplication without it.
qtsingleapplication.h:
line 70:
qtsingleapplication.h:line 70:
//QtSingleApplication(int &argc, char **argv, Type type);
qtsingleapplication.cpp:
第176行:
qtsingleapplication.cpp:line 176:
/*QtSingleApplication::QtSingleApplication(int &argc, char **argv, Type type) :
QApplication(argc, argv, type)
{
sysInit();
}*/
这篇关于移动到Qt5时的编译错误:“类型”尚未声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!