Cookies
-
That is the general use case. Just set the cookie jar for a shared QNetworkAccessManager. I really suggest you to see the code of Rekonq or Arora. Those are fully fledged browser built on top of QtWebKit.
-
i have looked at them.... is there a simple explanation of the syntax of Qt? As i don't understand the layout of the code very well currently (it took me a week to figure out where to put the line to enable plugins, and even then that was only because i guessed correctly.)
-
Maybe you should start with the tutorials then? The API of Qt is very consistent, once you get the general concept, you know where to look when working with new components.
-
which tutorials? there are to many :D i', downloading the full set of qt course material right now in an effort to figure that out :D
-
ok, hopefully i'm starting to understand the syntax, however i keep getting the "expected unqualified-id before '->' token" error, what am i doing wrong? here is what i currently have:
@Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled, true);
}
Widget::~Widget()
{
delete ui;
}
void Widget::on_Finish_clicked()
{
Widget::Widget->tabWidget->Login->Login_Main->QWebView::setUrl(const QUrl &"http://magicduel.com/");
}
@as you can tell, i have successfully enabled plugins (well as successfully as linux lets you anyways) but i need to make sure that once it gets the cookies (which i'm currently avoiding as they seem to be the most difficult part) it will go to the right page, and since when you click that button it currently refreshes all of the pages, i can use it to do it the right way and send them all to their correct url's. Currently, it's my opinion that extracting page elements will be easier than getting the cookies working :D
-
i'm trying to get that web view object to go to the url i put in there.
-
well i figured out part of it, haven't figured out how to get it to set the url though....
@ui->Login_Main->QWebView::setUrl();@
that's what i've figured out so far..... and it doesn't do me much good since i can't figure out how to define the url i want to set it to.
-
try this ...
@
ui->nameofyourwebview->load(QUrl("http://qt.nokia.com/"));
@I assume you have added a QWebView to your designer form, in that case ui->nameofyourwebview should be available.
-
ah, that's where i was off, i was trying to set url, not load it, and Login_Main is the QWebView..... now why doesn't it want to actually change to that page...., ok, just figured out why it wouldn't change the page, you can't have some refrences to one in the slots of the ui as well as refrences in the script, you have to have it just in the script or just in the slots, or you won't get the script refrences to that object.
-
chetankjain, any chance you could attempt to explain what danilocesar tried (and failed) to explain? and btw i'm definately making a lot of progress towards learning qt :D the designer interface is straight foward, the scripting, not so much :D and if you want something to happen on the loading of a form you put it under the section where the form is created right?
-
and i'm now stuck as to where to go from here towards enabling cookies across all the frames, here is the code i have currently.
@Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled, true);
ui->Advnt_Main->stop();
ui->Ally_Main->stop();
ui->Equipt_Main->stop();
ui->Log_Main->stop();
ui->Magic_Main->stop();
ui->Msgs_Main->stop();
ui->Nav_Main->stop();
ui->News_Main->stop();
ui->Prgrs_Main->stop();
ui->Profile_Main->stop();
ui->Quest_Main->stop();
ui->Story_Main->stop();
void QNetworkAccessManager::setCookieJar ( QNetworkCookieJar * cookieJar );
}
Widget::~Widget()
{
delete ui;
}void Widget::on_actionLoggedin_triggered()
{
ui->Login_Main->load( QUrl("http://magicduel.com/") );
ui->Advnt_Main->load( QUrl("http://magicduel.com/dlg/dlg.adventurelog.php") );
ui->Ally_Main->load( QUrl("http://magicduel.com/ifrm/ifrm.alliance.php") );
ui->Equipt_Main->load( QUrl("http://magicduel.com/ifrm/ifrm.weapons.php") );
ui->Log_Main->load( QUrl("http://magicduel.com/dlg/dlg.battlelog.php") );
ui->Magic_Main->load( QUrl("http://magicduel.com/ifrm/ifrm.magicpage.php") );
ui->Msgs_Main->load( QUrl("http://magicduel.com/dlg/dlg.messagelist.php?categ=") );
ui->Nav_Main->load( QUrl("http://magicduel.com/layout.php") );
ui->News_Main->load( QUrl("http://magicduel.com/dlg/dlg.changelog.php") );
ui->Prgrs_Main->load( QUrl("http://magicduel.com/dlg/dlg.todaysprofile.php") );
ui->Profile_Main->load( QUrl("http://magicduel.com/ifrm/ifrm.profile.php") );
ui->Quest_Main->load( QUrl("http://magicduel.com/pages/info.rpcquestlist.php") );
ui->Story_Main->load( QUrl("http://magicduel.com/ifrm/ifrm.quest.php&rs=cof") );
}
@ -
i keep getting
error: invalid use of qualified-name ‘QNetworkAccessManager::setCookieJar’
when i try to compile it.
-
ok, i've gotten it to create the cookie jar, i just need to figure out how to refer them all to the same cookie jar. here is what i have so far:
@Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled, true);
ui->Advnt_Main->stop();
ui->Ally_Main->stop();
ui->Equipt_Main->stop();
ui->Log_Main->stop();
ui->Magic_Main->stop();
ui->Msgs_Main->stop();
ui->Nav_Main->stop();
ui->News_Main->stop();
ui->Prgrs_Main->stop();
ui->Profile_Main->stop();
ui->Quest_Main->stop();
ui->Story_Main->stop();
ui->Login_Main->page()->networkAccessManager()->setCookieJar ( new QNetworkCookieJar() );
ui->Advnt_Main->page()->networkAccessManager()->setCookieJar ( new QNetworkCookieJar() );
ui->Ally_Main->page()->networkAccessManager()->setCookieJar ( new QNetworkCookieJar() );
ui->Equipt_Main->page()->networkAccessManager()->setCookieJar ( new QNetworkCookieJar() );
ui->Log_Main->page()->networkAccessManager()->setCookieJar ( new QNetworkCookieJar() );
ui->Magic_Main->page()->networkAccessManager()->setCookieJar ( new QNetworkCookieJar() );
ui->Msgs_Main->page()->networkAccessManager()->setCookieJar ( new QNetworkCookieJar() );
ui->Nav_Main->page()->networkAccessManager()->setCookieJar ( new QNetworkCookieJar() );
ui->News_Main->page()->networkAccessManager()->setCookieJar ( new QNetworkCookieJar() );
ui->Prgrs_Main->page()->networkAccessManager()->setCookieJar ( new QNetworkCookieJar() );
ui->Profile_Main->page()->networkAccessManager()->setCookieJar ( new QNetworkCookieJar() );
ui->Quest_Main->page()->networkAccessManager()->setCookieJar ( new QNetworkCookieJar() );
ui->Story_Main->page()->networkAccessManager()->setCookieJar ( new QNetworkCookieJar() );
}
Widget::~Widget()
{
delete ui;
}void Widget::on_actionLoggedin_triggered()
{
ui->Login_Main->load( QUrl("http://magicduel.com/") );
ui->Advnt_Main->load( QUrl("http://magicduel.com/dlg/dlg.adventurelog.php") );
ui->Ally_Main->load( QUrl("http://magicduel.com/ifrm/ifrm.alliance.php") );
ui->Equipt_Main->load( QUrl("http://magicduel.com/ifrm/ifrm.weapons.php") );
ui->Log_Main->load( QUrl("http://magicduel.com/dlg/dlg.battlelog.php") );
ui->Magic_Main->load( QUrl("http://magicduel.com/ifrm/ifrm.magicpage.php") );
ui->Msgs_Main->load( QUrl("http://magicduel.com/dlg/dlg.messagelist.php?categ=") );
ui->Nav_Main->load( QUrl("http://magicduel.com/layout.php") );
ui->News_Main->load( QUrl("http://magicduel.com/dlg/dlg.changelog.php") );
ui->Prgrs_Main->load( QUrl("http://magicduel.com/dlg/dlg.todaysprofile.php") );
ui->Profile_Main->load( QUrl("http://magicduel.com/ifrm/ifrm.profile.php") );
ui->Quest_Main->load( QUrl("http://magicduel.com/pages/info.rpcquestlist.php") );
ui->Story_Main->load( QUrl("http://magicduel.com/ifrm/ifrm.quest.php") );
}void QNetworkCookieJar ( QObject *)
{}
QNetworkCookieJar::~QNetworkCookieJar ()
{}
@ -
You need to create one instance of QNetworkAccessManager, set your cookiejar on it, and call QWebPage::setNetworkAccessManager() on every page with the instance of QNetworkAccessManager you created.
I suggest you to have a look at a book of C++. You make some basic mistakes like when you called the following directly in your code:
@void QNetworkAccessManager::setCookieJar ( QNetworkCookieJar * cookieJar );@I think coding with Qt will be much easier when you understand C++ better.
-
bq. I suggest you to have a look at a book of C++.
Thinking about it, reading the code of Arora can also help you a lot. This use case is a basic use case in the code base of Arora.
-
any chance you could show me a bit of sample code that i would have to use to get it working? It's the last problem I have before i can get my program actually off the ground, because currently it would take just over an hour to login to all of the frames, because the site forces a 5 minute delay between logins to the same account, meaning you have to wait between logging in in each frame, and that's just not very practical.
-
And i do have the source code of Arora, the problem is, it dynamically creates the webview's where-as i already have all of the web views. The sourcecode of arora has actually been useful though, as it has helped me solve some of the problems i've encountered.
-
Quick and dirty?
@
QNetworkAccessManager *const networkAccessManager = new QNetworkAccessManager(this);
ui->Login_Main->page()->setNetworkAccessManager(networkAccessManager);
ui->Advnt_Main->page()->setNetworkAccessManager(networkAccessManager);
@etc.
[edit: added code tag / chetankjain]
-
THANK YOU!!!!!!!!!!!!!!!!!!!!!!!