PDA

View Full Version : Recive the form post with QWebKit?



cochise
24th August 2009, 19:44
Its possible?
In my app i want show a HTML form in a QWebPage and recive the post of this.It's possible? Or i need a external code (like perl or PHP) for this?
How be the action propriety? Javascript is necessary?
Who class can recive the post in QT?

burnttoy
25th August 2009, 10:02
Hi Cochise,

I have an answer and a question for everyone.

If you derive a class from QWebPage and add your own acceptNavigationRequest like this



class MyWebPage : public QWebPage
{
public:
MyWebPage(QObject *p_parent = 0);

protected:
virtual bool acceptNavigationRequest ( QWebFrame * frame, const QNetworkRequest & request, NavigationType type );
};


Then when the user submits a form acceptNavigationRequest will be called with type set to NavigationTypeFormSubmitted.

If you look in the QNetworkRequest you should be able to find the URL and other information relating to the form submission.

Now, here is my question. The request object will have headers, url etc but I can't get the POST information which is in the body of the HTTP request.

This works fine for GET form submissions as the form key/value pairs are encoded in the URL and available via request.url().encodedQueryItems()

Sooo... How do I get to the body information in the QNetworkRequest from an HTML "POST" form submission.

Yours,
Matthew.

wysota
25th August 2009, 10:32
Maybe you should get rid of the form and use real Qt widgets there? You can embed such a "form" into QWebView using WebKit's plugin infrastructure if you really have to have the form as part of the webpage.

cochise
26th August 2009, 07:39
nice. I will try this.
But...
what is the max size of the url in the QWebKit?

and wysota. I no wanna a html model for data input because it's more simple for thirty party contribuitions.
The program is a RPG sheet manager, then i intent create a unique code for making any sheet is possible. And if the sheets are in html is possible add functions for this like experience calculate of characters with javascript. And the apparency of the sheets is very customizable.

It's my first really program after exercises and examples.
Tanks folks.

wysota
26th August 2009, 09:13
and wysota. I no wanna a html model for data input because it's more simple for thirty party contribuitions.
More simple than what?


And if the sheets are in html is possible add functions for this like experience calculate of characters with javascript. And the apparency of the sheets is very customizable.

I'd use Designer for designing and QUiLoader and QtScript for the logic and have the same functionality without reaching my left ear with my right foot.