Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7249049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:14:01+00:00 2026-05-28T22:14:01+00:00

Hi all I have one problem. I am connecting QT with php script..Everything works

  • 0

Hi all I have one problem.
I am connecting QT with php script..Everything works fine, but can somone help me how to receive php result from it.
here is my code :

void MainWindow::Dodaj_korisnika(QUrl url)
{
    //reply = qnam.get(QNetworkRequest(url));
    ////////////////////////////////////////////////////
    QUrl params;
    params.addQueryItem("action","Dodaj_korisnika");
    params.addQueryItem("ime",ui->lineEdit);
    params.addQueryItem("prezime",ui->lineEdit_2);
    params.addQueryItem("broj",ui->lineEdit_3);
    params.addQueryItem("adresa",ui->lineEdit_4);

        QByteArray data;
        data.append(params.toString());
        data.remove(0,1);

        QNetworkRequest request;
        request.setUrl(url);
        request.setHeader(QNetworkRequest::ContentTypeHeader,
        QVariant("application/x-www-form-urlencoded"));
        QNetworkAccessManager *manager = new QNetworkAccessManager(this);
        QNetworkReply *reply = manager->post(request, data);
        connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
}

And I have found on forums that I need to use this function:

void MainWindow::replyFinished(QNetworkReply *reply)
{
    QString data = reply->readAll().trimmed();
    // document.setContent(reply);
}

But ofc I am not getting anything into this function..Is it possible to read from QT manager variable? I am receiving xml result. And I want to put it as QDomDocument is that possible?
Please give me some hint or some example if you have some time..
Thank’s all!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T22:14:02+00:00Added an answer on May 28, 2026 at 10:14 pm

    Are you sure the PHP script received something?

    • First you are creating a signal and slot each time you are posting
    • Second you create the connection after posting
    • Third verify that your query is well formed and that the php script is receiving it. If you have the script log\print incoming messages

    Edit: This is How it should look like

    // early in the code, like in the constructor 
    void MainWindow::init(){
      this->manager = new QNetworkAccessManager(this);
      connect(this->manager, SIGNAL(finished(QNetworkReply*)), 
              this, SLOT(replyFinished(QNetworkReply*)));
    }
    
    void MainWindow::Dodaj_korisnika(QUrl url){
    
        QUrl params;
        params.addQueryItem("action","Dodaj_korisnika");
        params.addQueryItem("ime",ui->lineEdit);
        params.addQueryItem("prezime",ui->lineEdit_2);
        params.addQueryItem("broj",ui->lineEdit_3);
        params.addQueryItem("adresa",ui->lineEdit_4);
    
        QByteArray data;
        data.append(params.toString());
        data.remove(0,1);
    
        QNetworkRequest request;
        request.setUrl(url);
        request.setHeader(QNetworkRequest::ContentTypeHeader,
        QVariant("application/x-www-form-urlencoded"));
    
        //Here you don't need to get the reply, it will be the same given to 
        //MainWindow::replyFinished
        this->manager->post(request, data);
    
    }
    
    void MainWindow::replyFinished(QNetworkReply *reply){
        //Use the reply as you wish
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am adding more than one link button during runtime but they all have
I have some tables. These tables all have one column in common called 'classified_id':
Is it possible to have one jQuery ready block executed after all others have
I have one master page which applies to all pages in this website. On
I have one hibernate sequence, that generates all sequence-numbers in my app. When I
I have one question regarding domain account. I have one domain controller where all
I have one abstract class -let's say myBase. And I want all the classes
I'd like to have one interface for all my grid related tasks.The tasks implement
All the googling around hasn't found an answer for me yet... I have one
I know zero javascript, and have one simple task: Find all text in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.