Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Interact with a QQmlApplicationEngine html page.
Forum Updated to NodeBB v4.3 + New Features

Interact with a QQmlApplicationEngine html page.

Scheduled Pinned Locked Moved Solved General and Desktop
18 Posts 3 Posters 5.0k 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
    bask185
    wrote on last edited by
    #1

    I just set up a QtWebEngine which opens an HTML file. I have not written the HTML myself. I need to interact with it.

    I have been told that it's name gets changef when a user gives certain inputs. What the user has done is than stored in the name. This was principle is being used succesfully with visual basic 6. Anyways the precise details are also a bit of a mistery to me. Long story short, all I need is to get data out of the webview browser's html

    alt text
    I hope the screenshot works for once -_-"

    I am trying to get the data out of it with:

    connect(engine, &QQmlApplicationEngine::objectNameChanged, this, &MainWindow::browserInteraction);
    

    But as you can guess, it's giving me an error message

    /home/user/Dropbox/GUI/GUI_Qt/mainwindow.cpp:63: error: no matching function for call to ‘MainWindow::connect(QQmlApplicationEngine&, void (QObject::*)(const QString&, QObject::QPrivateSignal), MainWindow*, void (MainWindow::*)())’
        connect(engine, &QQmlApplicationEngine::objectNameChanged, this, &MainWindow::browserInteraction);
                                                                                                        ^
    

    I have a function 'browserInteraction' in which I want to retrieve the objectname and process it to see if I can use this method.

    jsulmJ 1 Reply Last reply
    0
    • jsulmJ jsulm

      @bask185 said in Interact with a QQmlApplicationEngine html page.:

      QWebview

      Why don't you use http://doc.qt.io/qt-5/qwebengineview.html? QtWebKit is discontinued QWebEngine should be used instead.

      B Offline
      B Offline
      bask185
      wrote on last edited by
      #17

      @jsulm Becuz I sometimes have no idea of how to get my stuff to work, hence my presence on this here forum ;)

      Anways my entire app works like a charm, mostly thanks to your efforts, So thank you!

      Even the titleChanged() signal works out of the box, I only have to retrieve some information out of a column somewhere

      jsulmJ 1 Reply Last reply
      0
      • B bask185

        I just set up a QtWebEngine which opens an HTML file. I have not written the HTML myself. I need to interact with it.

        I have been told that it's name gets changef when a user gives certain inputs. What the user has done is than stored in the name. This was principle is being used succesfully with visual basic 6. Anyways the precise details are also a bit of a mistery to me. Long story short, all I need is to get data out of the webview browser's html

        alt text
        I hope the screenshot works for once -_-"

        I am trying to get the data out of it with:

        connect(engine, &QQmlApplicationEngine::objectNameChanged, this, &MainWindow::browserInteraction);
        

        But as you can guess, it's giving me an error message

        /home/user/Dropbox/GUI/GUI_Qt/mainwindow.cpp:63: error: no matching function for call to ‘MainWindow::connect(QQmlApplicationEngine&, void (QObject::*)(const QString&, QObject::QPrivateSignal), MainWindow*, void (MainWindow::*)())’
            connect(engine, &QQmlApplicationEngine::objectNameChanged, this, &MainWindow::browserInteraction);
                                                                                                            ^
        

        I have a function 'browserInteraction' in which I want to retrieve the objectname and process it to see if I can use this method.

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @bask185 Is engine a pointer?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        B 1 Reply Last reply
        0
        • B Offline
          B Offline
          bask185
          wrote on last edited by bask185
          #3

          Facepalm -_-" .....it is now, but now my application crashes before it starts.

          The connect line crashes the program, outcommenting it, removes the crash.

          Also I changed this: engine.load(QUrl(QStringLiteral("qrc:/resources/img/webview.qml")));
          in this: engine->load(QUrl(QStringLiteral("qrc:/resources/img/webview.qml")));
          to keep the compiler happy. When I execute this line of code the program also crashes.

          In MaindWindow.h: QQmlApplicationEngine *engine;

          jsulmJ 1 Reply Last reply
          0
          • jsulmJ jsulm

            @bask185 Is engine a pointer?

            B Offline
            B Offline
            bask185
            wrote on last edited by
            #4

            @jsulm Do you know if/how I can find the cause to why it crashes. I mean does Qt creator has some kind of crash log or something?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #5

              Hi,

              You seem to be using a MinGW build of Qt, then you should already have a debugger. Just start your application in debug mode and you should get some interesting stuff.

              Hope it helps.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              2
              • B bask185

                Facepalm -_-" .....it is now, but now my application crashes before it starts.

                The connect line crashes the program, outcommenting it, removes the crash.

                Also I changed this: engine.load(QUrl(QStringLiteral("qrc:/resources/img/webview.qml")));
                in this: engine->load(QUrl(QStringLiteral("qrc:/resources/img/webview.qml")));
                to keep the compiler happy. When I execute this line of code the program also crashes.

                In MaindWindow.h: QQmlApplicationEngine *engine;

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #6

                @bask185 Did you create an instance of QQmlApplicationEngine and assign the pointer to engine?

                engine = new QQmlApplicationEngine();
                

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                2
                • B Offline
                  B Offline
                  bask185
                  wrote on last edited by bask185
                  #7

                  No I forgot this. I will learn it someday, I hope ;)

                  This webview is becomming a payne, I'm running in one issue after the other.

                  I just solved the obstacle of closing the webview. I could not use -> exit() or-> close() because those are signals which kill the entire program.

                  Eventually I learned that I can close the webbrowser with the function ''->deleteLater();" but this works one whole time. The 2nd time I try to open the webbrowser...

                  The inferior stopped because it received a signal from the operating system.
                  
                  Signal name : 
                  SIGSEGV
                  Signal meaning : 
                  Segmentation fault
                  
                  

                  aka crash.

                  I just want to be able to close the webview just like you do when you press the x. The x is not present on my target device so I need to close the webview in code, I suppose that hiding it underneath my GUI is also an acceptable option. If it is possible that is.

                  And I still cannot retrieve information out of the html. In the html there is this line

                  document.title=txtString
                  

                  The idea is.... was that when this this rule gets executed, the object name changes and I could get information out of it using the 'objectNameChanged' signal. But it does not seem to work. The html also has it's own exit option but it does not.... exits anything. I added document.close(); to the function in question, but nothing -_-"*

                  Anyways I am open to suggestions.... on Qt's end ofcourse. I have 0,0 experience and knowledge of QML and HTML. And if it would be up to me, I'd be recreating the html in a new Qt window.

                  jsulmJ 1 Reply Last reply
                  1
                  • B bask185

                    No I forgot this. I will learn it someday, I hope ;)

                    This webview is becomming a payne, I'm running in one issue after the other.

                    I just solved the obstacle of closing the webview. I could not use -> exit() or-> close() because those are signals which kill the entire program.

                    Eventually I learned that I can close the webbrowser with the function ''->deleteLater();" but this works one whole time. The 2nd time I try to open the webbrowser...

                    The inferior stopped because it received a signal from the operating system.
                    
                    Signal name : 
                    SIGSEGV
                    Signal meaning : 
                    Segmentation fault
                    
                    

                    aka crash.

                    I just want to be able to close the webview just like you do when you press the x. The x is not present on my target device so I need to close the webview in code, I suppose that hiding it underneath my GUI is also an acceptable option. If it is possible that is.

                    And I still cannot retrieve information out of the html. In the html there is this line

                    document.title=txtString
                    

                    The idea is.... was that when this this rule gets executed, the object name changes and I could get information out of it using the 'objectNameChanged' signal. But it does not seem to work. The html also has it's own exit option but it does not.... exits anything. I added document.close(); to the function in question, but nothing -_-"*

                    Anyways I am open to suggestions.... on Qt's end ofcourse. I have 0,0 experience and knowledge of QML and HTML. And if it would be up to me, I'd be recreating the html in a new Qt window.

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #8

                    @bask185 Why not just call hide()?
                    If you delete it and try to access it later then yes your app will crash as you're trying to access memory you freed before...

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

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

                      @jsulm said in Interact with a QQmlApplicationEngine html page.:

                      @bask185 Why not just call hide()?

                      For once I am on step ahead of you, I think ;) The answer to this question:

                      /home/user/Dropbox/GUI/GUI_Qt/mainwindow.cpp:151: error: ‘class QQmlApplicationEngine’ has no member named ‘hide’
                         engine->hide();
                                 ^
                      

                      The code in the setup is now:

                      QtWebEngine::initialize();
                      engine->load(QUrl(QStringLiteral("qrc:/resources/img/webview.qml")));
                      engine->hide();
                      

                      @jsulm said in Interact with a QQmlApplicationEngine html page.:

                      If you delete it and try to access it later then yes your app will crash as you're trying to access memory you freed before...

                      I figured something like that is why I tried to call ::initialize() again before opening. But I believe 'deleteLater()' deletes the object/member I declared in the header file -->> crash ???

                      jsulmJ 1 Reply Last reply
                      0
                      • B bask185

                        @jsulm said in Interact with a QQmlApplicationEngine html page.:

                        @bask185 Why not just call hide()?

                        For once I am on step ahead of you, I think ;) The answer to this question:

                        /home/user/Dropbox/GUI/GUI_Qt/mainwindow.cpp:151: error: ‘class QQmlApplicationEngine’ has no member named ‘hide’
                           engine->hide();
                                   ^
                        

                        The code in the setup is now:

                        QtWebEngine::initialize();
                        engine->load(QUrl(QStringLiteral("qrc:/resources/img/webview.qml")));
                        engine->hide();
                        

                        @jsulm said in Interact with a QQmlApplicationEngine html page.:

                        If you delete it and try to access it later then yes your app will crash as you're trying to access memory you freed before...

                        I figured something like that is why I tried to call ::initialize() again before opening. But I believe 'deleteLater()' deletes the object/member I declared in the header file -->> crash ???

                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by
                        #10

                        @bask185 You cannot call anything on something what was already deleted (deleteLater() deletes the object).

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

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

                          @jsulm said in Interact with a QQmlApplicationEngine html page.:

                          @bask185 You cannot call anything on something what was already deleted (deleteLater() deletes the object).

                          Yes and I scrolled through the list of functions but I cannot find anything which simply closes the webview window

                          jsulmJ 1 Reply Last reply
                          0
                          • B bask185

                            @jsulm said in Interact with a QQmlApplicationEngine html page.:

                            @bask185 You cannot call anything on something what was already deleted (deleteLater() deletes the object).

                            Yes and I scrolled through the list of functions but I cannot find anything which simply closes the webview window

                            jsulmJ Offline
                            jsulmJ Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on last edited by
                            #12

                            @bask185 QWebView is derived from QWidget and QWidget has hide() method

                            https://forum.qt.io/topic/113070/qt-code-of-conduct

                            B 1 Reply Last reply
                            0
                            • jsulmJ jsulm

                              @bask185 QWebView is derived from QWidget and QWidget has hide() method

                              B Offline
                              B Offline
                              bask185
                              wrote on last edited by
                              #13

                              @jsulm said in Interact with a QQmlApplicationEngine html page.:

                              @bask185 QWebView is derived from QWidget and QWidget has hide() method

                              But 'member that the thing I am using:

                              engine = new QQmlApplicationEngine();
                              

                              is not derived from a QWidget IIRC.

                              I am using this QML file:

                              import QtQuick 2.0
                              import QtQuick.Window 2.0
                              import QtWebEngine 1.0
                              
                              Window {
                                  width: 1024
                                  height: 750
                                  visible: true
                                  WebEngineView {
                                      anchors.fill: parent
                                      url: "qrc:/resources/img/frmSSPeditor.html"
                                  }
                              }
                              

                              to open the .html

                              And I did this because this was recommended to me on this here forum.
                              @raven-worx said in Browsers and Java Script.:

                              @bask185
                              QtWebkit is deprecated in the meantime and has been replaced by QtWebEngine (based on Chromium).
                              Try using WebEngineView instead.

                              This + I am not seeing the QWebview widget in Qt creator.

                              alt text
                              No suggestions for hide, can only find 'handle'. I am telling you hide() isn't there

                              jsulmJ 1 Reply Last reply
                              0
                              • B bask185

                                @jsulm said in Interact with a QQmlApplicationEngine html page.:

                                @bask185 QWebView is derived from QWidget and QWidget has hide() method

                                But 'member that the thing I am using:

                                engine = new QQmlApplicationEngine();
                                

                                is not derived from a QWidget IIRC.

                                I am using this QML file:

                                import QtQuick 2.0
                                import QtQuick.Window 2.0
                                import QtWebEngine 1.0
                                
                                Window {
                                    width: 1024
                                    height: 750
                                    visible: true
                                    WebEngineView {
                                        anchors.fill: parent
                                        url: "qrc:/resources/img/frmSSPeditor.html"
                                    }
                                }
                                

                                to open the .html

                                And I did this because this was recommended to me on this here forum.
                                @raven-worx said in Browsers and Java Script.:

                                @bask185
                                QtWebkit is deprecated in the meantime and has been replaced by QtWebEngine (based on Chromium).
                                Try using WebEngineView instead.

                                This + I am not seeing the QWebview widget in Qt creator.

                                alt text
                                No suggestions for hide, can only find 'handle'. I am telling you hide() isn't there

                                jsulmJ Offline
                                jsulmJ Offline
                                jsulm
                                Lifetime Qt Champion
                                wrote on last edited by
                                #14

                                @bask185 How did you add that engine to your GUI? Does it have a parent widget? Is it in a layout?

                                https://forum.qt.io/topic/113070/qt-code-of-conduct

                                B 1 Reply Last reply
                                0
                                • jsulmJ jsulm

                                  @bask185 How did you add that engine to your GUI? Does it have a parent widget? Is it in a layout?

                                  B Offline
                                  B Offline
                                  bask185
                                  wrote on last edited by
                                  #15

                                  @jsulm said in Interact with a QQmlApplicationEngine html page.:

                                  @bask185 How did you add that engine to your GUI? Does it have a parent widget? Is it in a layout?

                                  It has no parent Widgets. In the header file I declare: QQmlApplicationEngine *engine;
                                  In the setup I initialize it:
                                  engine = new QQmlApplicationEngine(); //(this action is called initializing right??)
                                  and I also perform QtWebEngine::initialize();

                                  In a function I call: engine->load(QUrl(QStringLiteral("qrc:/resources/img/webview.qml")));
                                  And this line opens a new window with the .qml which opens the .html

                                  It is not related to any .ui I also have no controll where the window appears. The reso of the target device is that small that it is just right.

                                  But if you can tell me how to install the QWebview widget in Qt creator, that also works for me.

                                  jsulmJ 1 Reply Last reply
                                  0
                                  • B bask185

                                    @jsulm said in Interact with a QQmlApplicationEngine html page.:

                                    @bask185 How did you add that engine to your GUI? Does it have a parent widget? Is it in a layout?

                                    It has no parent Widgets. In the header file I declare: QQmlApplicationEngine *engine;
                                    In the setup I initialize it:
                                    engine = new QQmlApplicationEngine(); //(this action is called initializing right??)
                                    and I also perform QtWebEngine::initialize();

                                    In a function I call: engine->load(QUrl(QStringLiteral("qrc:/resources/img/webview.qml")));
                                    And this line opens a new window with the .qml which opens the .html

                                    It is not related to any .ui I also have no controll where the window appears. The reso of the target device is that small that it is just right.

                                    But if you can tell me how to install the QWebview widget in Qt creator, that also works for me.

                                    jsulmJ Offline
                                    jsulmJ Offline
                                    jsulm
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #16

                                    @bask185 said in Interact with a QQmlApplicationEngine html page.:

                                    QWebview

                                    Why don't you use http://doc.qt.io/qt-5/qwebengineview.html? QtWebKit is discontinued QWebEngine should be used instead.

                                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    B 1 Reply Last reply
                                    0
                                    • jsulmJ jsulm

                                      @bask185 said in Interact with a QQmlApplicationEngine html page.:

                                      QWebview

                                      Why don't you use http://doc.qt.io/qt-5/qwebengineview.html? QtWebKit is discontinued QWebEngine should be used instead.

                                      B Offline
                                      B Offline
                                      bask185
                                      wrote on last edited by
                                      #17

                                      @jsulm Becuz I sometimes have no idea of how to get my stuff to work, hence my presence on this here forum ;)

                                      Anways my entire app works like a charm, mostly thanks to your efforts, So thank you!

                                      Even the titleChanged() signal works out of the box, I only have to retrieve some information out of a column somewhere

                                      jsulmJ 1 Reply Last reply
                                      0
                                      • B bask185

                                        @jsulm Becuz I sometimes have no idea of how to get my stuff to work, hence my presence on this here forum ;)

                                        Anways my entire app works like a charm, mostly thanks to your efforts, So thank you!

                                        Even the titleChanged() signal works out of the box, I only have to retrieve some information out of a column somewhere

                                        jsulmJ Offline
                                        jsulmJ Offline
                                        jsulm
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #18

                                        @bask185 Glad to hear it works now :-)

                                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                                        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