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. Get confirmation that a key has reached JS
Forum Update on Monday, May 27th 2025

Get confirmation that a key has reached JS

Scheduled Pinned Locked Moved Solved Qt WebKit
webview webkitjscriptkeyevent
33 Posts 4 Posters 12.6k Views
  • 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.
  • M McLion
    13 Dec 2016, 15:42

    @Konstantin-Tokarev
    Need some help ...
    I have the following:
    in h:

    #include <QWebPage>
    class DBGWebPage : public QWebPage
    {
    Q_OBJECT
      public:
        explicit DBGWebPage(QObject *parent = 0);
      protected:
        void javaScriptConsoleMessage( const QString & message, int lineNumber, const QString & sourceID );
    };
    

    in cpp:

    void DBGWebPage::javaScriptConsoleMessage( const QString & message, int lineNumber, const QString & sourceID )
    {
      qDebug() << message << lineNumber << sourceID;
    }
    

    and my webGUI's are derived from qWebView:

    QWebView *webGUI = new QWebView(QTGUI_MainWindow::centralWidget());
    

    How do I make it use the reimplementation of javaScriptConsoleMessage()?

    K Offline
    K Offline
    Konstantin Tokarev
    wrote on 13 Dec 2016, 15:44 last edited by
    #12

    @McLion QWebView::setPage

    M 2 Replies Last reply 13 Dec 2016, 16:24
    0
    • K Konstantin Tokarev
      13 Dec 2016, 15:44

      @McLion QWebView::setPage

      M Offline
      M Offline
      McLion
      wrote on 13 Dec 2016, 16:24 last edited by
      #13

      @Konstantin-Tokarev
      Thanks .. seems to be too late for today ... I don't get it to build ... dam...

      1 Reply Last reply
      0
      • K Konstantin Tokarev
        13 Dec 2016, 15:44

        @McLion QWebView::setPage

        M Offline
        M Offline
        McLion
        wrote on 13 Dec 2016, 16:53 last edited by
        #14

        @Konstantin-Tokarev
        There's something I don't get ... probably soemthing with these C++ classes I'm always stumbling over:

        #include <QWebPage>
        class DBGWebPage : public QWebPage
        {
        Q_OBJECT
          public:
            explicit DBGWebPage(QObject *parent = 0);
            QWebPage *DebugWebPage;
          protected:
            void javaScriptConsoleMessage( const QString & message, int lineNumber, const QString & sourceID );
        };
        
        DBGWebPage::DBGWebPage(QObject *parent) :
          QWebPage(parent)
        {
          //QWebPage* DebugWebPage = new QWebPage;
          DebugWebPage = new QWebPage(this);
        }
        
        QWebView * QTGUI_MainWindow::CreateNewWebGUI(int iID)
        {
          // check if already existing
          if(webGUIMap.value(iID) != 0) { qDebug("GUI %d existing", iID); return false; }
        
          // check for max GUI count here
          if(iID > GUI_COUNT_MAX) { qDebug("GUI %d failed - Max GUI ID is %d", iID, GUI_COUNT_MAX); return false; }
        
          // create new webGUI and add it to the list
          QWebView *webGUI = new QWebView(QTGUI_MainWindow::centralWidget());
          webGUIMap.insert(iID, webGUI);
        
          // make some basic settings to the new GUI
          webGUI->setPage(DBGWebPage::DebugWebPage);
          webGUI->setObjectName(QString::fromUtf8("webGUI%1").arg(iID));
        ......
        

        Fehler:object missing in reference to 'DBGWebPage::DebugWebPage'

        K M 3 Replies Last reply 13 Dec 2016, 16:54
        0
        • M McLion
          13 Dec 2016, 16:53

          @Konstantin-Tokarev
          There's something I don't get ... probably soemthing with these C++ classes I'm always stumbling over:

          #include <QWebPage>
          class DBGWebPage : public QWebPage
          {
          Q_OBJECT
            public:
              explicit DBGWebPage(QObject *parent = 0);
              QWebPage *DebugWebPage;
            protected:
              void javaScriptConsoleMessage( const QString & message, int lineNumber, const QString & sourceID );
          };
          
          DBGWebPage::DBGWebPage(QObject *parent) :
            QWebPage(parent)
          {
            //QWebPage* DebugWebPage = new QWebPage;
            DebugWebPage = new QWebPage(this);
          }
          
          QWebView * QTGUI_MainWindow::CreateNewWebGUI(int iID)
          {
            // check if already existing
            if(webGUIMap.value(iID) != 0) { qDebug("GUI %d existing", iID); return false; }
          
            // check for max GUI count here
            if(iID > GUI_COUNT_MAX) { qDebug("GUI %d failed - Max GUI ID is %d", iID, GUI_COUNT_MAX); return false; }
          
            // create new webGUI and add it to the list
            QWebView *webGUI = new QWebView(QTGUI_MainWindow::centralWidget());
            webGUIMap.insert(iID, webGUI);
          
            // make some basic settings to the new GUI
            webGUI->setPage(DBGWebPage::DebugWebPage);
            webGUI->setObjectName(QString::fromUtf8("webGUI%1").arg(iID));
          ......
          

          Fehler:object missing in reference to 'DBGWebPage::DebugWebPage'

          K Offline
          K Offline
          Konstantin Tokarev
          wrote on 13 Dec 2016, 16:54 last edited by
          #15
          This post is deleted!
          1 Reply Last reply
          0
          • M McLion
            13 Dec 2016, 16:53

            @Konstantin-Tokarev
            There's something I don't get ... probably soemthing with these C++ classes I'm always stumbling over:

            #include <QWebPage>
            class DBGWebPage : public QWebPage
            {
            Q_OBJECT
              public:
                explicit DBGWebPage(QObject *parent = 0);
                QWebPage *DebugWebPage;
              protected:
                void javaScriptConsoleMessage( const QString & message, int lineNumber, const QString & sourceID );
            };
            
            DBGWebPage::DBGWebPage(QObject *parent) :
              QWebPage(parent)
            {
              //QWebPage* DebugWebPage = new QWebPage;
              DebugWebPage = new QWebPage(this);
            }
            
            QWebView * QTGUI_MainWindow::CreateNewWebGUI(int iID)
            {
              // check if already existing
              if(webGUIMap.value(iID) != 0) { qDebug("GUI %d existing", iID); return false; }
            
              // check for max GUI count here
              if(iID > GUI_COUNT_MAX) { qDebug("GUI %d failed - Max GUI ID is %d", iID, GUI_COUNT_MAX); return false; }
            
              // create new webGUI and add it to the list
              QWebView *webGUI = new QWebView(QTGUI_MainWindow::centralWidget());
              webGUIMap.insert(iID, webGUI);
            
              // make some basic settings to the new GUI
              webGUI->setPage(DBGWebPage::DebugWebPage);
              webGUI->setObjectName(QString::fromUtf8("webGUI%1").arg(iID));
            ......
            

            Fehler:object missing in reference to 'DBGWebPage::DebugWebPage'

            M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 13 Dec 2016, 16:57 last edited by
            #16

            Hi
            webGUI->setPage(DBGWebPage::DebugWebPage);
            I would expect be something like
            DBGWebPage *page=new DBGWebPage();
            webGUI->setPage(page->DebugWebPage);

            The other syntax seems odd ?

            M 1 Reply Last reply 13 Dec 2016, 17:06
            0
            • M McLion
              13 Dec 2016, 16:53

              @Konstantin-Tokarev
              There's something I don't get ... probably soemthing with these C++ classes I'm always stumbling over:

              #include <QWebPage>
              class DBGWebPage : public QWebPage
              {
              Q_OBJECT
                public:
                  explicit DBGWebPage(QObject *parent = 0);
                  QWebPage *DebugWebPage;
                protected:
                  void javaScriptConsoleMessage( const QString & message, int lineNumber, const QString & sourceID );
              };
              
              DBGWebPage::DBGWebPage(QObject *parent) :
                QWebPage(parent)
              {
                //QWebPage* DebugWebPage = new QWebPage;
                DebugWebPage = new QWebPage(this);
              }
              
              QWebView * QTGUI_MainWindow::CreateNewWebGUI(int iID)
              {
                // check if already existing
                if(webGUIMap.value(iID) != 0) { qDebug("GUI %d existing", iID); return false; }
              
                // check for max GUI count here
                if(iID > GUI_COUNT_MAX) { qDebug("GUI %d failed - Max GUI ID is %d", iID, GUI_COUNT_MAX); return false; }
              
                // create new webGUI and add it to the list
                QWebView *webGUI = new QWebView(QTGUI_MainWindow::centralWidget());
                webGUIMap.insert(iID, webGUI);
              
                // make some basic settings to the new GUI
                webGUI->setPage(DBGWebPage::DebugWebPage);
                webGUI->setObjectName(QString::fromUtf8("webGUI%1").arg(iID));
              ......
              

              Fehler:object missing in reference to 'DBGWebPage::DebugWebPage'

              K Offline
              K Offline
              Konstantin Tokarev
              wrote on 13 Dec 2016, 17:05 last edited by
              #17

              @McLion You derive DBGWebPage from QWebPage and add QWebPage* field to it, then try to use that QWebPage* field (which is vanilla QWebPage, not DBGWebPage) as it was static filed of DBGWebPage.

              1 Reply Last reply
              0
              • M mrjj
                13 Dec 2016, 16:57

                Hi
                webGUI->setPage(DBGWebPage::DebugWebPage);
                I would expect be something like
                DBGWebPage *page=new DBGWebPage();
                webGUI->setPage(page->DebugWebPage);

                The other syntax seems odd ?

                M Offline
                M Offline
                McLion
                wrote on 13 Dec 2016, 17:06 last edited by McLion
                #18

                @mrjj
                Thanks.
                In fact, the other syntax seemed wrong.
                You code builds without error, however, crashes with SIGSEGV.

                K 1 Reply Last reply 13 Dec 2016, 17:21
                0
                • M McLion
                  13 Dec 2016, 17:06

                  @mrjj
                  Thanks.
                  In fact, the other syntax seemed wrong.
                  You code builds without error, however, crashes with SIGSEGV.

                  K Offline
                  K Offline
                  Konstantin Tokarev
                  wrote on 13 Dec 2016, 17:21 last edited by
                  #19

                  @McLion Because it should be

                  DBGWebPage *page=new DBGWebPage();
                  webGUI->setPage(page);

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    McLion
                    wrote on 13 Dec 2016, 17:24 last edited by
                    #20

                    I somehow understand all you're saying, but I so far am not able to modify my code to not crash.
                    Currently ended up with (modified to it while Konstantin was writing it too):

                    DBGWebPage *page=new DBGWebPage();
                    webGUI->setPage(page);
                    

                    and an empty constructor.
                    Still crashing .... I'm stumped.

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      Konstantin Tokarev
                      wrote on 13 Dec 2016, 17:37 last edited by
                      #21

                      remove DebugWebPage and all code messing with it

                      M 1 Reply Last reply 13 Dec 2016, 17:44
                      0
                      • M Offline
                        M Offline
                        McLion
                        wrote on 13 Dec 2016, 17:41 last edited by
                        #22

                        Found something.
                        It actually works if comment 2 signal connects for the page, but I need these two.

                        • networkAccessManager for SSL errors
                        • and the JS bridge
                          If the page has been set, do I need to connect these in a different way or do these now go to the wrong object?
                        QWebView * QTGUI_MainWindow::CreateNewWebGUI(int iID)
                        {
                          // check if already existing
                          if(webGUIMap.value(iID) != 0) { qDebug("GUI %d existing", iID); return false; }
                        
                          // check for max GUI count here
                          if(iID > GUI_COUNT_MAX) { qDebug("GUI %d failed - Max GUI ID is %d", iID, GUI_COUNT_MAX); return false; }
                        
                          // create new webGUI and add it to the list
                          QWebView *webGUI = new QWebView(QTGUI_MainWindow::centralWidget());
                          webGUIMap.insert(iID, webGUI);
                        
                          // make some basic settings to the new GUI
                        DBGWebPage *page=new DBGWebPage();
                        webGUI->setPage(page);
                        
                          webGUI->setObjectName(QString::fromUtf8("webGUI%1").arg(iID));
                        //qDebug() << "New webGUI:" << webGUI;
                        //qDebug() << "Map:" << iID << webGUIMap.value(iID);
                          webGUI->setStyleSheet(QString::fromUtf8("background-color: rgba(0, 0, 0, 0);"));
                          webGUI->setUrl(QUrl("about:blank"));
                          webGUI->setRenderHints(QPainter::SmoothPixmapTransform|QPainter::TextAntialiasing);
                          webGUI->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
                          webGUI->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
                          webGUI->setGeometry(0, 0, SCREEN_SIZE_X, SCREEN_SIZE_Y);
                          webGUI->setFocusPolicy(Qt::StrongFocus);
                          webGUI->setMouseTracking(true);
                          webGUI->setAcceptDrops(true);
                          webGUIeventFilter *webGUIEvFil = new webGUIeventFilter;
                          webGUI->installEventFilter(webGUIEvFil);
                          webGUI->hide();
                        
                          // connect load progress and finished signals
                          connect(webGUI, SIGNAL(loadProgress(int)), ui->webGUIChangeProgressBar, SLOT(setValue(int)));
                          connect(webGUI, SIGNAL(loadFinished(bool)), this, SLOT(webGUI_loadFinished(bool)));
                        
                          // prepare adding objects to JavaScript (bridge from JS to native code)
                        //  connect(webGUI->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(populateJavaScriptWindowObject()));
                        
                          // setup SSL error handling
                        //  connect(webGUI->page()->networkAccessManager(), SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError> & )),
                        //  this, SLOT(HandleGUIsslErrors(QNetworkReply*, const QList<QSslError> & )));
                        
                          return webGUI;
                        }
                        
                        1 Reply Last reply
                        0
                        • K Konstantin Tokarev
                          13 Dec 2016, 17:37

                          remove DebugWebPage and all code messing with it

                          M Offline
                          M Offline
                          McLion
                          wrote on 13 Dec 2016, 17:44 last edited by
                          #23

                          @Konstantin-Tokarev
                          Did so - all removed.

                          1 Reply Last reply
                          0
                          • M Offline
                            M Offline
                            McLion
                            wrote on 15 Dec 2016, 16:55 last edited by McLion
                            #24

                            I can not find what I'm doing wrong. The console debug works, as long as I have deactivated the JS bridge.

                            DBGWebPage *page=new DBGWebPage();
                            webGUI->setPage(page);
                            // the following lines that use the new page seem to work
                            webGUI->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
                            webGUI->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
                            // and the following line - that I need - let it crash upon boot:
                            connect(webGUI->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(populateJavaScriptWindowObject()));
                            

                            If I don't use setPage() to change the page that the webView generates by default, the JS bridge works perfectly.
                            What am I doing wrong to use the page of my own class with the debug added AND use the JS bridge?

                            A 1 Reply Last reply 21 Dec 2016, 18:04
                            0
                            • M Offline
                              M Offline
                              McLion
                              wrote on 16 Dec 2016, 14:22 last edited by McLion
                              #25

                              Anyone an idea what I'm doing wrong here?
                              The code does not crash while connecting. It seems to crashes when the first web page is loaded and the loadProgress or loadFinished signal is sent from the webView.
                              Edit/Add:
                              On second thought, it probably crashes when the javaScriptWindowObjectCleared() is called the first time.

                              A 1 Reply Last reply 17 Dec 2016, 06:45
                              0
                              • M McLion
                                16 Dec 2016, 14:22

                                Anyone an idea what I'm doing wrong here?
                                The code does not crash while connecting. It seems to crashes when the first web page is loaded and the loadProgress or loadFinished signal is sent from the webView.
                                Edit/Add:
                                On second thought, it probably crashes when the javaScriptWindowObjectCleared() is called the first time.

                                A Offline
                                A Offline
                                ambershark
                                wrote on 17 Dec 2016, 06:45 last edited by
                                #26

                                @McLion Throw it in gdb or your debugger of choice and give us a backtrace and we can probably tell ya what the issue is.

                                My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

                                M 1 Reply Last reply 19 Dec 2016, 09:00
                                0
                                • A ambershark
                                  17 Dec 2016, 06:45

                                  @McLion Throw it in gdb or your debugger of choice and give us a backtrace and we can probably tell ya what the issue is.

                                  M Offline
                                  M Offline
                                  McLion
                                  wrote on 19 Dec 2016, 09:00 last edited by
                                  #27

                                  @ambershark
                                  Unfortunately, I don't have any debugger running on this eLinux target.

                                  1 Reply Last reply
                                  0
                                  • M McLion
                                    15 Dec 2016, 16:55

                                    I can not find what I'm doing wrong. The console debug works, as long as I have deactivated the JS bridge.

                                    DBGWebPage *page=new DBGWebPage();
                                    webGUI->setPage(page);
                                    // the following lines that use the new page seem to work
                                    webGUI->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
                                    webGUI->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
                                    // and the following line - that I need - let it crash upon boot:
                                    connect(webGUI->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(populateJavaScriptWindowObject()));
                                    

                                    If I don't use setPage() to change the page that the webView generates by default, the JS bridge works perfectly.
                                    What am I doing wrong to use the page of my own class with the debug added AND use the JS bridge?

                                    A Offline
                                    A Offline
                                    ambershark
                                    wrote on 21 Dec 2016, 18:04 last edited by
                                    #28

                                    @McLion said in Get confirmation that a key has reached JS:

                                    I can not find what I'm doing wrong. The console debug works, as long as I have deactivated the JS bridge.

                                    DBGWebPage *page=new DBGWebPage();
                                    webGUI->setPage(page);
                                    // the following lines that use the new page seem to work
                                    webGUI->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
                                    webGUI->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
                                    // and the following line - that I need - let it crash upon boot:
                                    connect(webGUI->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(populateJavaScriptWindowObject()));
                                    

                                    If I don't use setPage() to change the page that the webView generates by default, the JS bridge works perfectly.
                                    What am I doing wrong to use the page of my own class with the debug added AND use the JS bridge?

                                    @McLion Ok if that's the case you'll need to move to using qDebug() or some sort of cout/logfile debugging to figure out what's going on. If you need a logger for linux you're welcome to use mine at https://github.com/ambershark-mike/sharklog. It's not feature complete yet but is definitely more than usable. I use it in a number of projects.

                                    Anyway, my guess with your crash is that webGUI or page() or mainFrame() is invalid. One of those is causing the issue almost guaranteed. Assuming the crash is actually on that line. So for instance if you were using my logger you could check it with code like:

                                    // sorry for the casts to (int) on the pointers, I don't have hex address/pointer support in the logger yet.
                                    // it's a side project I don't have a ton of time for. :)
                                    LoggerStream() << "webGUI: " << (int)webGUI << SHARKLOG_END;
                                    LoggerStream() << "page: " << (int)webGUI->page() << SHARKLOG_END;
                                    LoggerStream() << "mainFrame: " << (int)webGUI->page()->mainFrame() << SHARKLOG_END;
                                    

                                    The reason we do all those logs on a separate line is if any of them are bad they will crash. Put these in before your connect and check which object is bad. Probably a null (0), but potentially it has been deleted. If that is the case and it is a dangling pointer it is going to be harder to find without a debugger.

                                    My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

                                    M 1 Reply Last reply 22 Dec 2016, 10:05
                                    1
                                    • A ambershark
                                      21 Dec 2016, 18:04

                                      @McLion said in Get confirmation that a key has reached JS:

                                      I can not find what I'm doing wrong. The console debug works, as long as I have deactivated the JS bridge.

                                      DBGWebPage *page=new DBGWebPage();
                                      webGUI->setPage(page);
                                      // the following lines that use the new page seem to work
                                      webGUI->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
                                      webGUI->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
                                      // and the following line - that I need - let it crash upon boot:
                                      connect(webGUI->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(populateJavaScriptWindowObject()));
                                      

                                      If I don't use setPage() to change the page that the webView generates by default, the JS bridge works perfectly.
                                      What am I doing wrong to use the page of my own class with the debug added AND use the JS bridge?

                                      @McLion Ok if that's the case you'll need to move to using qDebug() or some sort of cout/logfile debugging to figure out what's going on. If you need a logger for linux you're welcome to use mine at https://github.com/ambershark-mike/sharklog. It's not feature complete yet but is definitely more than usable. I use it in a number of projects.

                                      Anyway, my guess with your crash is that webGUI or page() or mainFrame() is invalid. One of those is causing the issue almost guaranteed. Assuming the crash is actually on that line. So for instance if you were using my logger you could check it with code like:

                                      // sorry for the casts to (int) on the pointers, I don't have hex address/pointer support in the logger yet.
                                      // it's a side project I don't have a ton of time for. :)
                                      LoggerStream() << "webGUI: " << (int)webGUI << SHARKLOG_END;
                                      LoggerStream() << "page: " << (int)webGUI->page() << SHARKLOG_END;
                                      LoggerStream() << "mainFrame: " << (int)webGUI->page()->mainFrame() << SHARKLOG_END;
                                      

                                      The reason we do all those logs on a separate line is if any of them are bad they will crash. Put these in before your connect and check which object is bad. Probably a null (0), but potentially it has been deleted. If that is the case and it is a dangling pointer it is going to be harder to find without a debugger.

                                      M Offline
                                      M Offline
                                      McLion
                                      wrote on 22 Dec 2016, 10:05 last edited by
                                      #29

                                      @ambershark
                                      Oh, I'm using qDebug() a lot since I have a serial console connected to the embedded target that allows me to see everything from Linux and interact with it as well.

                                      The problem is that from within a JS in webKit there is no qDebug().
                                      By subclassing webView and reimplementing javaScriptConsoleMessage() every console message in a JS (i.e. console.log("JS keyCode: " + event.keyCode);) can be catched in C++ code and forwarded to the console by using qDebug().
                                      Actually, this works ... as long as I don't connect the bridge and comment the following:

                                      // prepare adding objects to JavaScript (bridge from JS to native code)
                                      connect(webGUI->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(populateJavaScriptWindowObject()));
                                      

                                      So, I assume that the object in the connect is the issue because page() is not automatically derived from the webView as it was before and has been changed to page() from my subclass DBGWebPage.

                                      I just can't see what is wrong with the stuff I'm doing.
                                      Thanks a lot anyway.

                                      K 1 Reply Last reply 22 Dec 2016, 10:07
                                      0
                                      • M McLion
                                        22 Dec 2016, 10:05

                                        @ambershark
                                        Oh, I'm using qDebug() a lot since I have a serial console connected to the embedded target that allows me to see everything from Linux and interact with it as well.

                                        The problem is that from within a JS in webKit there is no qDebug().
                                        By subclassing webView and reimplementing javaScriptConsoleMessage() every console message in a JS (i.e. console.log("JS keyCode: " + event.keyCode);) can be catched in C++ code and forwarded to the console by using qDebug().
                                        Actually, this works ... as long as I don't connect the bridge and comment the following:

                                        // prepare adding objects to JavaScript (bridge from JS to native code)
                                        connect(webGUI->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(populateJavaScriptWindowObject()));
                                        

                                        So, I assume that the object in the connect is the issue because page() is not automatically derived from the webView as it was before and has been changed to page() from my subclass DBGWebPage.

                                        I just can't see what is wrong with the stuff I'm doing.
                                        Thanks a lot anyway.

                                        K Offline
                                        K Offline
                                        Konstantin Tokarev
                                        wrote on 22 Dec 2016, 10:07 last edited by
                                        #30

                                        @McLion Could you post self-contained project that can be built?

                                        M 1 Reply Last reply 22 Dec 2016, 10:23
                                        1
                                        • K Konstantin Tokarev
                                          22 Dec 2016, 10:07

                                          @McLion Could you post self-contained project that can be built?

                                          M Offline
                                          M Offline
                                          McLion
                                          wrote on 22 Dec 2016, 10:23 last edited by
                                          #31

                                          @Konstantin-Tokarev
                                          I'm not sure ... I think that should work if I share all Qt sources in my 'src' folder, does it?

                                          I am working and developing on Windows with Creator to have the output from the compiler and everything Creator offers. If it builds ok, I switch to my Linux Debian VM and build the ARM code from within the Linux console. The traget gets the code over the LAN directly from my Linux VM by NFS.
                                          The application can not really be run on windows because there are some hardware components and other stuff that is available on the target only. I mean it runs, but you can't do anything with it on windows.

                                          K 1 Reply Last reply 22 Dec 2016, 10:55
                                          0

                                          21/33

                                          13 Dec 2016, 17:37

                                          • Login

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