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. Compose pointer to property of object
Forum Updated to NodeBB v4.3 + New Features

Compose pointer to property of object

Scheduled Pinned Locked Moved Solved General and Desktop
c++pointerobjectsproperties
25 Posts 3 Posters 9.1k Views 2 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.
  • M Offline
    M Offline
    McLion
    wrote on 5 Apr 2016, 09:14 last edited by McLion 4 May 2016, 09:15
    #12

    Getting forward :-)
    The hint with the sender in the signal was great too. As if you would know before, I really stumbled over this - thanks!

    I came across an issue with the list though.
    There are no absolute positions in the list. Saying if 3 entries are made (0,1,2) and the second list (1) is cancelled for instance because it's not needed anymore, former entry 2 becomes entry 1.
    QList seems to always fill from the 0 up and there are no absolute positions.

    I either did not get all of QList or I may need to switch to some other solution - unfortunately- because it otherwise works a treat.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 5 Apr 2016, 09:40 last edited by mrjj 4 May 2016, 09:49
      #13

      hi
      Im not sure what wrong with QList since its dynamic and
      we cant have invalid pointers around ?
      else use a map
      http://doc.qt.io/qt-5/qmap.html
      QMap<int,QWebView * > map;
      QWebView *webGUI = new QWebView(this);
      ...
      map[1] =webGUI ;
      map[2] =nextwebGUI ;
      ...
      QWebView *w=map[2]; // it will stay "2"

      They wont change position as 1,2 is a key
      like map["onekey"] =webGUI ;
      but we use int as no need for string.
      so even if we remove map[1] then
      map[2] is still there.

      So maybe it works better for you ?

      1 Reply Last reply
      1
      • M Offline
        M Offline
        McLion
        wrote on 5 Apr 2016, 09:58 last edited by
        #14

        Tried quickly ... and the Map is exactly what I need.
        Thanks a million! .... I'll be back ;-)

        M 1 Reply Last reply 5 Apr 2016, 10:02
        0
        • M McLion
          5 Apr 2016, 09:58

          Tried quickly ... and the Map is exactly what I need.
          Thanks a million! .... I'll be back ;-)

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 5 Apr 2016, 10:02 last edited by
          #15

          @McLion
          super
          notice if you reuse the key
          map[1] =webGUI ;
          map[1] =nextwebGUI ;
          It will replace the web *.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            McLion
            wrote on 5 Apr 2016, 10:03 last edited by
            #16

            Thanks for the heads-up.
            I'll do some testing and experiment.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              McLion
              wrote on 5 Apr 2016, 14:16 last edited by
              #17

              So far, everything related to this threads question and the QMap as solution seems to work.

              I stumbled over something else while relacing the QwebView from the Designer by my 'on-demand' created one:
              I can not load an url, it crashes with sig11.

              I get the following connect error on bootup:

              QMetaObject::connectSlotsByName: No matching signal for on_webGUI_loadFinished(bool)
              

              which I dont understand and may be the cause.
              I have connected:

              connect(webGUI, SIGNAL(loadFinished(bool)), this, SLOT(on_webGUI_loadFinished(bool)));
              

              and in *.h as private slot:

              void on_webGUI_loadFinished(bool arg1);
              

              This worked before, with the QWebView from the Designer.
              Any idea? Thanks.

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mrjj
                Lifetime Qt Champion
                wrote on 5 Apr 2016, 14:26 last edited by
                #18

                @McLion said:

                no matching signal for on_webGUI_loadFinished(bool)

                Hi
                this warning comes as you name slot on_XXX
                This will trigger Qt auto connect feature so when you use
                a concrete connect you should rename it so it dont
                start with on__
                (right click it- refactor->rename)

                also please do
                qDebug() << "loadfin:" << connect(webGUI, SIGNAL(loadFinixxxx

                to see if it returns true; ( as in , it can connect)

                1 Reply Last reply
                1
                • M Offline
                  M Offline
                  McLion
                  wrote on 5 Apr 2016, 14:39 last edited by
                  #19

                  I wasn't aware that using on_ in the name will trigger any functionality!
                  Refactoring solved this problem - Thanks !

                  However, the signal 11 crash when trying to load an url seems to have some other cause .... I'm searching ;-)

                  1 Reply Last reply
                  0
                  • J Online
                    J Online
                    jsulm
                    Lifetime Qt Champion
                    wrote on 5 Apr 2016, 15:47 last edited by
                    #20

                    You're most probably dereferencing a null pointer. Signal 11 means SIGSEGV (segmentation error).

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

                    M 1 Reply Last reply 6 Apr 2016, 08:21
                    0
                    • J jsulm
                      5 Apr 2016, 15:47

                      You're most probably dereferencing a null pointer. Signal 11 means SIGSEGV (segmentation error).

                      M Offline
                      M Offline
                      McLion
                      wrote on 6 Apr 2016, 08:21 last edited by
                      #21

                      @jsulm
                      Yes - Thanks . Problem loacted, but not yet solved:

                      void QTGUI_MainWindow::populateJavaScriptWindowObject()
                      {
                        QWebView * webGUI = qobject_cast<QWebView *>(sender());
                        webGUI->page()->mainFrame()->addToJavaScriptWindowObject("NativeBridge", this);
                      }
                      

                      The sender is the JS and not the QWebView and so I do not get the pointer to the QWebView that I need. Instead, the pointer is 0x0 and then - of course - the addToJ... crashes.

                      Any idea how I get the pointer to the QWebView from which the JS is sending?
                      Thanks

                      1 Reply Last reply
                      0
                      • J Online
                        J Online
                        jsulm
                        Lifetime Qt Champion
                        wrote on 6 Apr 2016, 08:42 last edited by
                        #22

                        What is JS?

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

                        M 1 Reply Last reply 6 Apr 2016, 08:45
                        0
                        • J jsulm
                          6 Apr 2016, 08:42

                          What is JS?

                          M Offline
                          M Offline
                          McLion
                          wrote on 6 Apr 2016, 08:45 last edited by
                          #23

                          @jsulm
                          JavaScript (in/from QWebKit ... more precise page()->mainFrame().

                          1 Reply Last reply
                          0
                          • M Offline
                            M Offline
                            McLion
                            wrote on 6 Apr 2016, 11:33 last edited by
                            #24

                            I posted this as a separate question in the WebKit group.

                            1 Reply Last reply
                            0
                            • M Offline
                              M Offline
                              McLion
                              wrote on 6 Apr 2016, 14:57 last edited by
                              #25

                              Got it solved :-)

                              QWebFrame * webGUIframe = qobject_cast<QWebFrame >(sender());
                              QWebView * webGUI = (QWebView
                              )(webGUIframe->parent())->parent();
                              webGUI->page()->mainFrame()->addToJavaScriptWindowObject("NativeBridge", this);

                              1 Reply Last reply
                              0

                              21/25

                              6 Apr 2016, 08:21

                              • Login

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