• 4314阅读
  • 2回复

这样为什么不能qDebug出来 [复制链接]

上一主题 下一主题
离线wan2004
 

只看楼主 倒序阅读 楼主  发表于: 2009-03-19
main.cpp
  1. #include <QSslSocket>
  2. #include <iostream>
  3. #include <string>
  4. #include <QString>
  5. #include "my.h"
  6. #include <QDebug>
  7. using namespace std;
  8. int main(int argc, char *argv[])
  9. {
  10.     QSslSocket* socket = new QSslSocket;
  11.     My my1(socket);
  12.     socket->connectToHostEncrypted("pop.gmail.com",995);
  13. /*
  14.     if(!socket->waitForEncrypted())
  15.     {
  16.         qDebug() << socket->errorString();
  17.         return 1;
  18.     }
  19. */
  20.     string str;
  21.     getline(cin,str);
  22.     while(str != "EXIT")
  23.     {
  24.         QString qstr(str.c_str());
  25.         qDebug() << "you input str : " << qstr;
  26.         socket->write(qstr.toUtf8());
  27.         getline(cin,str);
  28.     }
  29.     delete socket;
  30.     return 0;
  31. }

my.cpp
  1. #include "my.h"
  2. #include <QDebug>
  3. void My::putIn()
  4. {
  5.     
  6.     qDebug() << "data :" <<this->socket->readAll().data(); //这句不会执行
  7. }
  8. My::My(QSslSocket* so)
  9. {
  10.     this->socket = so;
  11. connect(so,SIGNAL(encrypted()),this,SLOT(putIn()));//通知上面的方法了
  12. }

my.h
  1. #ifndef MY_H
  2. #define MY_H
  3. #include <QObject>
  4. #include <QSslSocket>
  5. class My : public QObject
  6. {
  7.     Q_OBJECT
  8.     public:
  9.         My(QSslSocket* so);
  10.         QSslSocket* socket;
  11.     public slots:
  12.         void putIn();
  13. };
  14. #endif // MY_H


一般链接到gmail了以后会有+OK的返回的
离线foxyz

只看该作者 1楼 发表于: 2009-03-19
#include <QDebug>
好像是
#include <QtDebug>
离线浪漫天使
只看该作者 2楼 发表于: 2009-03-19
pro文件里面加入
CONFIG += console

意思就是工程加入控制台支持。
快速回复
限100 字节
 
上一个 下一个