QNetworkAccessManager signals not working
-
@Defohin
if all connects are successfull (by returning true), the only thing i can think of is that the reply (or QNAM) or the object holding the slots are deleted? -
It's not being deleted, I'm using pointers to test if it has something to do with that, but it doesn't work either.
-
Hi,
can you try with a site that does not redirect to https e.g. http://en.cppreference.com/w/. Maybe that's a problem.
-Michael. -
It doesn't work either, I really don't know what is going on.
-
This post is deleted! -
Hi,
please try to makeQNetworkReply *reply
a class member variable. As you have it now it gets lost as soon as you leave the function. You will need it anyway in thereadyRead
slot.
-Michael. -
The problem was on the instance of the class, I had to use it as a pointer.
auto nytimes = new NYTimes; nytimes->parse();
instead of:
NYTimes nytimes; nytimes.parse();
Is there a reason for that?
-
Hi
It depends on the contextvoid Func() {
auto nytimes = new NYTimes;
nytimes->parse();
} // after here NYTimes still livesvoid Func() {
NYTimes nytimes;
nytimes.parse();
} // after here NYTimes is no more -
I was calling
NYTimes nytimes;
on the constructor of theQMainWindow
-
@Defohin said in QNetworkAccessManager signals not working:
NYTimes nytimes; on the constructor of the QMainWindow
So it means that at the time when
MainWindow was shown, nytimes would have been deleted.
Its called "running out of scope". Applies to all variables on the stack. -
Thank you, it's solved