#include <QtCore>#include <QtNetwork>int main(int argc, char** argv){ QCoreApplication app(argc, argv); QNetworkProxy proxy; proxy.setType(QNetworkProxy::HttpProxy); proxy.setHostName("10.10.10.202"); proxy.setPort(8080); proxy.setUser("username"); proxy.setPassword("password"); QNetworkProxy::setApplicationProxy(proxy); QTcpSocket s; s.setProxy(proxy); s.connectToHost(QHostAddress(QString("74.125.77.147")), 80, QIODevice::ReadWrite); if(s.waitForConnected(2000)) { qDebug() << "connectToHost!"; s.disconnectFromHost(); } else { qDebug() << s.error(); qDebug() << s.errorString(); } return 0;}
s.connectToHost(QHostAddress("74.125.77.147"), 80, QIODevice::ReadWrite);
C++ (Qt)s.connectToHost(QHostAddress(QString("hostname")), 80, QIODevice::ReadWrite);
C++ (Qt)s.connectToHost("hostname", 80, QIODevice::ReadWrite);
qDebug() << QHostInfo::fromName(QString("google.com")).addresses();
QHostInfo hi(QHostInfo::fromName("google.com")); qDebug() << hi.addresses() << "hi"; qDebug() << hi.error(); qDebug() << hi.errorString();