qtnetwork

qt simple tcp communication with ui projects

依然范特西╮ 提交于 2021-01-29 07:19:56
问题 I want to create a simple Tcp Communication project but I get some problems and I dont know how to solve that problem. When I try to find solution all people tell add this code (QT += network)on .pro file but in ui projects I dont have any pro file so I dont know the find the solution. //commu.h #ifndef COMMU_H #define COMMU_H #include <QtWidgets/QMainWindow> #include "ui_commu.h" #include <QtNetwork/QTcpSocket> #include <QObject> #include <QString> class commu : public QMainWindow { Q_OBJECT

How to use/include the QtNetwork Module

▼魔方 西西 提交于 2021-01-27 14:53:05
问题 I'm trying to develop a simple application in C++ that sends Files between two computers over LAN. After some research i found out that the QtNetwork Module is the way to go. I do include the QTcpServer and QTcpSocket in my solution. #include <QTcpServer> #include <QTcpSocket> I added the following path to the Additional Include Directories of my project. C:\Qt\5.14.2\msvc2017_64\include\QtNetwork I then tried a very simple Code. QTcpSocket* pTcpSocket = new QTcpSocket(); I get the

QNetworkAccessManager without finished signal

有些话、适合烂在心里 提交于 2020-06-28 12:39:37
问题 I want to request and response directly instead of using connect(..,SLOT(finished()),..,SLOT()) 回答1: You can use a QEventLoop so that the application waits and can handle other events at the same time. #include <QCoreApplication> #include <QNetworkAccessManager> #include <QNetworkReply> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QNetworkAccessManager *manager = new QNetworkAccessManager; QEventLoop loop; QObject::connect(manager, &QNetworkAccessManager::finished, &loop

QNetworkAccessManager without finished signal

拟墨画扇 提交于 2020-06-28 12:38:04
问题 I want to request and response directly instead of using connect(..,SLOT(finished()),..,SLOT()) 回答1: You can use a QEventLoop so that the application waits and can handle other events at the same time. #include <QCoreApplication> #include <QNetworkAccessManager> #include <QNetworkReply> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QNetworkAccessManager *manager = new QNetworkAccessManager; QEventLoop loop; QObject::connect(manager, &QNetworkAccessManager::finished, &loop

QNetworkAccessManager - How to send “PATCH” request

寵の児 提交于 2020-01-23 11:11:27
问题 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 ? 回答1: 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(

QNetworkAccessManager - How to send “PATCH” request

自作多情 提交于 2020-01-23 11:11:08
问题 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 ? 回答1: 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(

How can I add a progress for message sending operation (smtp) with blocking sockets API's?

£可爱£侵袭症+ 提交于 2020-01-06 06:44:16
问题 I'm using blocking sockets API (waitFor* functions) for sending mail by smtp protocol (it's a DLL modue). All operations are synchronous: connect->waitForConnected(timeout)->login->waitForReadyRead(timeout)->sendMessage->waitForBytesWritten(timeout) ->etc. I'm using blocking API, because QCoreApplication absence is required (DLL used by different apps, incl. non-qt-based). Blocking functions don't require event loop and it works fine. But how can I make a visual progress for long-term sending

QEventLoop proper usage

倖福魔咒の 提交于 2020-01-01 09:12:42
问题 I have doubts how should I use QEventLoop . I have 2 pieces of code, both of them work for me (get web resource downloaded). First one: QNetworkAccessManager *manager = new QNetworkAccessManager( this ); QNetworkRequest request; request.setUrl(QUrl(url)); request.setRawHeader("User-Agent", "Mozilla Firefox"); connect(manager, SIGNAL(finished(QNetworkReply*)),this,SLOT(replyFinished(QNetworkReply*))); manager->get( request ) ; QEventLoop loop; connect(manager, SIGNAL(finished(QNetworkReply*)),

Sending structured data over a network [closed]

▼魔方 西西 提交于 2019-12-24 07:36:29
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . I'm a begginer in network programming, so, sorry if my questions may appear a little obvious. I'm trying to send some data from Qt application to a Python server which will process them and send back some answer. the methods that allows me to send data in the QTcpSocket class are:

QNetworkAccessManager upload to local FTP server

不打扰是莪最后的温柔 提交于 2019-12-22 12:24:58
问题 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