Qtが組み込まれたVS2010を使用しています。クライアントとサーバーを実装しようとしていますが、UDPが使用されています。私は本Qt4プログラミングGUIC++から例を取りました。
実装は主にQtライブラリに基づいてQtNetwork
いますが、それを含めると、次のような不明なエラーがたくさん発生します。
Error 8 error C2653: 'System' : is not a class or namespace name ****\AssemblyInfo.cpp 3
Error 9 error C2871: 'Reflection' : a namespace with this name does not exist ****AssemblyInfo.cpp 3
エラーは、そのライブラリQtNetwork
が適切に含まれていなかった結果だと思います。この問題を解決する方法を教えてください。
私は自分の手段でそれを解決しようとし、次の行動を取りました:
VSの場合:Qt \ Qtプロジェクト設定\ネットワークライブラリを追加してから
qmake -project
、、qmake
nmake
.proファイルに文字列を追加し、
QT += network
次にqmake -project
、、qmake
nmake
それらの両方は、述べられた問題に対処することができませんでした。
#pragma once
#include <QWidget>
#include "QtNetwork"
#include <QtGui>
class QTimer;
class QUdpSocket;
class NetworkManagerServer : public QWidget
{
Q_OBJECT
public:
NetworkManagerServer(QWidget *parent = 0);
private slots:
void sendDatagramm();
private:
QUdpSocket* m_udpSocket;
QTimer* m_timer;
int m_messageNo;
};
#include "NetworkManagerServer.h"
NetworkManagerServer::NetworkManagerServer(QWidget *parent)
: QWidget(parent)
{
m_timer = new QTimer(this);
m_timer->start(2 * 1000);
m_udpSocket = new QUdpSocket(this);
m_messageNo = 1;
connect(m_timer, SIGNAL(timeout()), this, SLOT(broadcastDatagram()));
}
void NetworkManagerServer::sendDatagramm(void)
{
QByteArray datagramm;
QDataStream out (&datagramm, QIODevice::WriteOnly);
//out.setVersion(QDataStream::Qt_4_8);
out << "Hellow Qt::Network!";
m_udpSocket->writeDatagram(datagramm, QHostAddress::LocalHost,5824);
}
これが私が得るエラーのリストです:
Error 8 error C2653: 'System' : is not a class or namespace name ***\AssemblyInfo.cpp 3
Error 9 error C2871: 'Reflection' : a namespace with this name does not exist ***AssemblyInfo.cpp 3
Error 10 error C2653: 'System' : is not a class or namespace name ***AssemblyInfo.cpp 4
Error 11 error C2871: 'CompilerServices' : a namespace with this name does not exist ***AssemblyInfo.cpp 4
Error 12 error C2653: 'System' : is not a class or namespace name ***AssemblyInfo.cpp 5
Error 13 error C2871: 'InteropServices' : a namespace with this name does not exist ***AssemblyInfo.cpp 5
等々