Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. Cookies
Forum Updated to NodeBB v4.3 + New Features

Cookies

Scheduled Pinned Locked Moved Qt WebKit
24 Posts 3 Posters 15.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    benjamin.poulain
    wrote on last edited by
    #3

    Note that Arora has a very good CookieJar: "http://github.com/Arora/arora/tree/master/src/network/cookiejar/":http://github.com/Arora/arora/tree/master/src/network/cookiejar/

    It could be a good start to see how to write one.

    [edit: fixed hyperlink / $chetankjain ]

    1 Reply Last reply
    0
    • 1 Offline
      1 Offline
      1blah111111
      wrote on last edited by
      #4

      The problem is i have about 13 different web frames, and i need the cookie gotten in one of them to transfer to all of the others.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        benjamin.poulain
        wrote on last edited by
        #5

        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.

        1 Reply Last reply
        0
        • 1 Offline
          1 Offline
          1blah111111
          wrote on last edited by
          #6

          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.)

          1 Reply Last reply
          0
          • B Offline
            B Offline
            benjamin.poulain
            wrote on last edited by
            #7

            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.

            1 Reply Last reply
            0
            • 1 Offline
              1 Offline
              1blah111111
              wrote on last edited by
              #8

              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

              1 Reply Last reply
              0
              • 1 Offline
                1 Offline
                1blah111111
                wrote on last edited by
                #9

                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

                1 Reply Last reply
                0
                • ? This user is from outside of this forum
                  ? This user is from outside of this forum
                  Guest
                  wrote on last edited by
                  #10

                  The syntax is wrong, your creator should have pointed this out to you. What exactly are you trying to do in the method on_Finish_clicked() ?

                  1 Reply Last reply
                  0
                  • 1 Offline
                    1 Offline
                    1blah111111
                    wrote on last edited by
                    #11

                    i'm trying to get that web view object to go to the url i put in there.

                    1 Reply Last reply
                    0
                    • 1 Offline
                      1 Offline
                      1blah111111
                      wrote on last edited by
                      #12

                      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.

                      1 Reply Last reply
                      0
                      • ? This user is from outside of this forum
                        ? This user is from outside of this forum
                        Guest
                        wrote on last edited by
                        #13

                        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.

                        1 Reply Last reply
                        0
                        • 1 Offline
                          1 Offline
                          1blah111111
                          wrote on last edited by
                          #14

                          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.

                          1 Reply Last reply
                          0
                          • 1 Offline
                            1 Offline
                            1blah111111
                            wrote on last edited by
                            #15

                            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?

                            1 Reply Last reply
                            0
                            • 1 Offline
                              1 Offline
                              1blah111111
                              wrote on last edited by
                              #16

                              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") );
                              }
                              @

                              1 Reply Last reply
                              0
                              • 1 Offline
                                1 Offline
                                1blah111111
                                wrote on last edited by
                                #17

                                i keep getting

                                error: invalid use of qualified-name ‘QNetworkAccessManager::setCookieJar’

                                when i try to compile it.

                                1 Reply Last reply
                                0
                                • 1 Offline
                                  1 Offline
                                  1blah111111
                                  wrote on last edited by
                                  #18

                                  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 ()
                                  {

                                  }
                                  @

                                  1 Reply Last reply
                                  0
                                  • B Offline
                                    B Offline
                                    benjamin.poulain
                                    wrote on last edited by
                                    #19

                                    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.

                                    1 Reply Last reply
                                    0
                                    • B Offline
                                      B Offline
                                      benjamin.poulain
                                      wrote on last edited by
                                      #20

                                      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.

                                      1 Reply Last reply
                                      0
                                      • 1 Offline
                                        1 Offline
                                        1blah111111
                                        wrote on last edited by
                                        #21

                                        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.

                                        1 Reply Last reply
                                        0
                                        • 1 Offline
                                          1 Offline
                                          1blah111111
                                          wrote on last edited by
                                          #22

                                          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.

                                          1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved