• 5769阅读
  • 4回复

QUdpSocket的问题 [复制链接]

上一主题 下一主题
离线zxwind
 

只看楼主 倒序阅读 楼主  发表于: 2009-05-16
— 本帖被 XChinux 从 General Qt Programming 移动到本区(2011-01-02) —
我在使用QUdpSocket出现了很奇怪的问题

相关代码如下:

#include <QMessageBox>
#include <QtNetwork/QUdpSocket>
#include <QtNetwork/QHostAddress>
#include "ui_server.h"

class server: public QMainWindow
{Q_OBJECT
public: server(QWidget *parent = 0);
private slots:
        void about();
        void sendmsg();
private:
        Ui::ServerMainWindow ui;
        QUdpSocket *udpSocket;

};


server::server(QWidget *parent):QMainWindow(parent)
{
udpSocket = new QUdpSocket(this);

    ui.setupUi(this);
 connect(ui.aboutAction, SIGNAL(triggered()), this, SLOT(about()));



connect(ui.SendmsgButton,SIGNAL(clicked()),this,SLOT(sendmsg()));
}


结果编译无法通过,错误信息:

D:/project/server/server.cpp:5: undefined reference to `_imp___ZN10QUdpSocketC1EP7QObject'
D:/project/server/server.cpp:5: undefined reference to `_imp___ZN10QUdpSocketC1EP7QObject'
:-1: error: collect2: ld returned 1 exit status

报错的代码就是
udpSocket = new QUdpSocket(this);

我用的windows下的qt creator
离线hercules

只看该作者 1楼 发表于: 2009-05-16
确认你的pro文件中是否有这么一句
QT       += network
我的QQ号:337396132
欢迎大家加我为好友,一起学习Qt
离线zxwind

只看该作者 2楼 发表于: 2009-05-16
加了之后还是一样的错误
离线hercules

只看该作者 3楼 发表于: 2009-05-17
引用第2楼zxwind于2009-05-16 22:01发表的  :
加了之后还是一样的错误


Clean Project
Run Qmake
我的QQ号:337396132
欢迎大家加我为好友,一起学习Qt
离线zxwind

只看该作者 4楼 发表于: 2009-05-17
多谢,现在可以了
pro文件里的句子要加空格
加上
QT += network
就可以了
快速回复
限100 字节
 
上一个 下一个