使用Qt 5.2.1编译旧的Qt项目(可能由Qt 4.8创建):
蓝使者开源:

#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仓库中的提交引用:



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();
}*/

09-07 10:12