qtnetwork

QNetworkAccessManager - No such signal

孤街浪徒 提交于 2019-12-11 01:48:21
问题 void MainWindow::handleGetReply(QNetworkReply *reply) { qDebug() << reply; } void MainWindow::on_getDetailsButton_clicked() { QNetworkAccessManager *manager = new QNetworkAccessManager(this); connect( manager, SIGNAL(finished(QNetwokReply *reply)), this, SLOT(handleGetReply(QNetworkReply*))); manager->get(QNetworkRequest(QUrl("http://google.com"))); } For some reason this doesn't work, and I have the following message: QObject::connect: No such signal QNetworkAccessManager::finished

Getting MAC ID in Qt

断了今生、忘了曾经 提交于 2019-12-10 15:12:39
问题 I am using the following code to get the MAC ID in Qt. main.cpp #include <QtCore/QCoreApplication> #include "QtNetwork/QNetworkInterface" #include "QString" QString getMacAddress() { foreach(QNetworkInterface interface, QNetworkInterface::allInterfaces()) { // Return only the first non-loopback MAC Address if (!(interface.flags() & QNetworkInterface::IsLoopBack)) return interface.hardwareAddress(); QString text = interface.hardwareAddress(); qDebug() << text; } return QString(); } int main

Webpage returning HTTP 406 error only when connecting from Qt

核能气质少年 提交于 2019-12-10 13:48:36
问题 I have a test page setup at http://mlecturedownload.com/test-qt.php that has the following code: <?php $foo = $_GET['foo']; if ($foo == "0" || $foo == "1") { echo $foo; } else { echo "Invalid foo"; } Going to this page in a web browser and modifying the value of foo works fine, and using curl works fine as well. But when I send a request from Qt I get an HTTP 406 error code, which means "Not acceptable". Here is how I make the request: void MainWindow::on_send_clicked() { QString url = "http:

problem in making custom root certificate store for SSL using QT?

大憨熊 提交于 2019-12-08 06:44:34
问题 I am developing my custom browser in Qt using QWebView and I am trying to make my own root cert store of trusted certificates which are taken from mozilla project. I have used QSslSocket::setDefaultCaCertificates() to override the default certificates. But I am not able to load https://www.gmail.com , where as in mozilla it works. I have set all required root certs for gmail to my store. can anyone guide me ? 回答1: The reason you can't connect is because the SSL certificate (with serial 2F:DF

QNetworkAccessManager upload to local FTP server

自闭症网瘾萝莉.ら 提交于 2019-12-06 12:34:34
I can download from the server but I can't upload to it. It uploads the file but it's an empty file. This is basically what I'm doing: QString filename="Data.txt"; QFile file( filename ); file.open(QIODevice::ReadWrite); file.write("HELLO") ; QUrl urlup("ftp://127.0.0.1/file.txt"); urlup.setPassword("123"); urlup.setUserName("user"); urlup.setPort(21); QNetworkAccessManager *nam = new QNetworkAccessManager; QNetworkRequest requp(urlup); nam->put(requp,&file); file.close(); but it's not working; just uploads an empty file. user3220907 Instead of 127.0.0.1 use localhost Instead of setPort append

Qt 5: Access Cookies in QtWebEngine

我们两清 提交于 2019-12-06 11:04:38
问题 Is it possible to access the QNetworkCookieJar in QtWebEngine like you could before with QtWebKit ? I can't find it anywhere in the documentation... 回答1: From Qt 5.6 onwards you can use the QWebEngineCookieStore class. 回答2: QNetworkCookie is available for QtWebEngine, but only through the old QNetworkAccessManager as QtWebEngine is using its own HTTP implementation. You can notice this while reading one of the examples: contains(DEFINES, QWEBENGINEPAGE_SETNETWORKACCESSMANAGER) { HEADERS +=

Should I connect to QNetworkReply::error() as well?

不羁的心 提交于 2019-12-06 08:50:23
I have created a POST request and I connect to the finished() signal: QNetworkReply *reply = manager->post(request, postData.encodedQuery()); connect(reply, SIGNAL(finished()), this, SLOT(accept())); I want to be notified when the POST request has finished, regardless of whether it failed or succeeded. I have noticed in the documentation that there is also a QNetworkReply::error() signal, do I need to connect to it, too, or will finished() be called in all cases? evilruff Qt documentation states: void QNetworkReply::error(QNetworkReply::NetworkError code) [signal] This signal is emitted when

QNetworkAccessManager - How to send “PATCH” request

我们两清 提交于 2019-12-05 19:36:04
I am trying to send a "PATCH" request to my firebase application.As far as I read QNetworkManager doesn't support "Patch" request. How can I send "PATCH" request ? So we are clear that there is no method in QNetworkAccessManager named "patch" Therefore I have used "sendCustomRequest" but with QBuffer. Because QNetworkManager requires a QIODevice object. QString destination=""; currentNode.replace(QString("/").append(latestNode),""); destination .append(host) .append(currentNode) .append(".json"); QString jsonString=QString(QString("{").append("\"").append(latestNode).append("\"").append(":")

Get the ping from a remote target with Qt (Windows/Linux)

半世苍凉 提交于 2019-12-05 18:49:39
问题 Currently I use this code for retrieving the ping of a target system. However it works so far only under linux and it is likely dependent on the locale settings. To add support for windows will be likely even more complicated. Is there an easy way or library to get the ping of a target system? I mainly work with Qt, so it would be ideal if I could work with QSockets. #ifndef _WIN32 QProcess ping; ping.start("ping", QStringList() << "-c 1" << m_sHostName); if(ping.waitForFinished(250) ) {

Qt synchronous QNetworkAccessManager get

别来无恙 提交于 2019-12-04 09:34:51
What's the proper way to do a synchronous QNetworkAccessManager::get ? The qt wiki offers an approach, but states "it is not recommended to use this in real applications." The mailinglist offers a similar solution to the wiki. Yum may use something like this: QEventLoop loop; connect(_netReply, SIGNAL(finished()), &loop, SLOT(quit())); loop.exec(); The simple solution mentioned in the wiki and in the answer from yttrium is quite fragile since it doesn't handle all possible failure scenarios (such as proxy) and therefore shouldn't be used in a production environment, and unfortunately it has