Solved How can I get things from website
-
@JKSH
I had add qDebug() function in replyFinished() slot.
Here is my code.According to what you said it will print something out if i am in the same subnet.
And i'm sure that i am in the same subnet but why it still print NULL out like this?According to the picture i gave you, i assume that it will return "Updated ok!" back to me.
-
@victor-wang said in How can I get things from website:
Or i have to do it when the finished signal is up?
@JKSH already said several times that you have to do it in the slot connected to the finished() signal. So, yes do it in when you get finished() signal.
To your code: you call readAll twice - that is probably the reason why qDebug() << out; prints nothing. You should call readAll only once and then print the data. -
@jsulm
That mean i have to add QFile function into replyFinished() SLOT right?ReadAll function actually it call twice by itself and i don't know why it will happened.
I'm sure that i just call one time for the ReadAll function.
This is my code here.But when I add it into replyFinished() slot, it cannot connect to server.
The connect_url will return 0 for the second time to me like this.
What can i do? -
@victor-wang YES
"ReadAll function actually it call twice by itself" - how can a function call itself?
You do it twice, please check your own code again. First time: line 1999, second time line 2013. -
@jsulm
Thank you for telling me!
But now i still get nothing.
I had check several time that i can wget the Url on the console.
And i'm sure it is the right subnet and Url.
And i checked the check.txt file can be write nor read.
Why it still print NULL out? -
@victor-wang show your code
-
-
@victor-wang You cannot write in /home! (line 2019)
It should be /home/YOUR_USER_NAME/check.txt -
@victor-wang What do you get if you use wget with that URL? Any data?
-
-
@victor-wang You should print out reply->error()
If everything was fine then it should print out 0 (QNetworkReply::NoError) -
@jsulm
It shows no error.
That means everything was fine.
But why still have nothing?
Is there any possible because i receive a file? -
@victor-wang Is that out variable a QByteArray?
Also, what exactly does qDebug()<<out print out? -
-
@victor-wang can you do qDebug()<<out.size();?
-
-
@victor-wang said in How can I get things from website:
If it is how can i judge the signal and where do i have to add the function in?
You make a signal-slot connection, using
QObject::connect()
. When the signal is emitted, the connected slot will run automatically.This is a core feature of Qt. I recommend you spend some time to do tutorials to understand how to use signals and slots.
For the first of debugging and testing.
I will get this on my browser. hereOK, good. That means the server will give you text data.
For the second one, i'm not quite sure what does that mean.
Your code has
QUrl("http://192.168.100/59/...")
. Change this toQUrl("http://lists.qt-project.org/mailman/listinfo")
for testing.For third one, what does"QNetworkRequest constructly correctly"mean?
I thought i am using the library that Qt have already constructed.When you call
QNetworkRequest(QUrl(...));
you are constructing a QNetworkRequest.Let's check that your QNetworkReply is what you expect. Put this in your
replyFinished()
slot:qDebug() << reply->isFinished(); qDebug() << reply->error(); qDebug() << reply->request(); qDebug() << reply->url(); qDebug() << reply->rawHeaderPair();
For forth one, I'm sure i am on the same subnet because i can send this commend to my console
wget http://192.168.100.59/PLMS/TestCheck.asp?LSN=201503003009&EmpId=we9999&CPID=OS&CPKey=95Z0000000AF
And i will get the file and the content will show "updated ok".
OK, good.
-
for your Xming copy/paste problem to windows, take a look to this topic:
https://superuser.com/questions/440128/xming-clipboard-only-works-one-way
That should enable you to poste your code as text for us and not as pictures.
-
-