Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, May 2007
How to send data using POST


Message 1 in thread

Hi all,

I was browsing through the documentation one day and I saw the
QHttp::post member function. I noticed that the parameter taking in
the POST data key-value pairs is a QByteArray. So now I'm wondering,
given that you want to send key-value pairs (like HTML form data) to a
server via POST, how do you do encode the key value pairs into a
QByteArray for sending?

Thanks
Benjamin Lau

--
 [ signature omitted ] 

Message 2 in thread

Benjamin Lau wrote:
> Hi all,
> 
> I was browsing through the documentation one day and I saw the
> QHttp::post member function. I noticed that the parameter taking in
> the POST data key-value pairs is a QByteArray. So now I'm wondering,
> given that you want to send key-value pairs (like HTML form data) to a
> server via POST, how do you do encode the key value pairs into a
> QByteArray for sending?

The QByteArray is just a utf8 query string.

QByteArray data = QString("firstName=Benjamin&lastName=Lau").toUtf8();

-- 
 [ signature omitted ] 

Message 3 in thread

Hi all,

Ah...I see...now why didn't I think of that. Silly me.

Thanks a bunch!

Adieu
Benjamin Lau

--
 [ signature omitted ]