Unsolved How to get/parse pastepin raw content using qt5 ?
-
Oh, ok. So just for the record - that's not parsing. Parsing is a process of analyzing some input and transforming it into another form. what you seem to want is just fetching some data.
The code you posted looks ok. For networking and signal/slot connections to work you need a running event loop (
exec()
). I'm assuming you don't have one as this is common mistake when writing a console app.
Can you show your main() ?Btw. please surround code with ```, not html tags.
-
@Hanoosh
Hi
Your code does work.
please try
https://www.dropbox.com/s/9gkycyliz0h6cyp/netreader.zip?dl=0 -
@mrjj Thanks it works, is there anyway to make it simpler like in only one .cpp file with no header file?
-
@Hanoosh
Hi
no. there must be .h file.
the tool that make signal and slot works, called moc.exe, only reads .h files.
So class MyClass : public QObject must be in a .h file. -
Hi,
In fact yes, it's possible, you have to include the moc file at the end of the .cpp file to force moc to parse the .cpp file. It's used for Qt's unit tests. Note that it's not the usual way to do it. @mrjj's solution is the good clean classic.
-
@mrjj Thanks for the info and help, how to make it support ssl link?
-
@Hanoosh
Hi
Do you mean HTTPS ? -
@mrjj yes, thanks
im getting this with https link:
QSslSocket: cannot call unresolved function SSL_CTX_new QSslSocket: cannot call unresolved function SSL_library_init QSslSocket: cannot call unresolved function ERR_get_error
-
@Hanoosh
I think you need to set something with QSslConfiguration
and install OpenSSL binaries
https://forum.qt.io/topic/9376/solved-qnetworkaccessmanager-https-code-2-error-qnetworkreply-remotehostclosederror
(code in top)
request.setSslConfiguration(QSslConfiguration::defaultConfiguration());for binaries
http://slproweb.com/products/Win32OpenSSL.htmlThis is purely guessing so you might want to wait to see if someone knows exactly.
.
-
@mrjj Thanks, i've found the code below and i'm trying to implement in my code:
QNetworkAccessManager qnam; QSslConfiguration sslConfiguration(QSslConfiguration::defaultConfiguration()); SslConfiguration.setProtocol(QSsl::SslV3); QNetworkRequest req; req.setSslConfiguration(sslConfiguration); req.setUrl(QUrl("https://www.address.tld/")); QNetworkReply *rep = qnam->get(req);