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. Signalling from a thread to main window issue
QtWS25 Last Chance

Signalling from a thread to main window issue

Scheduled Pinned Locked Moved General and Desktop
8 Posts 2 Posters 1.9k 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.
  • D Offline
    D Offline
    dolevo
    wrote on last edited by
    #1

    Hi all,

    I have a gui application where I create an instance for my class. In my class (class1) I do some stuff but I also create a thread. I have some signal-slot connections from class1 to main window class, which works without any problem. However, I need to connect a signal from my thread to a signal in class1, which causes a problem apparently.

    The signal-slot between class1 and main window class is:
    @ connect(class1, SIGNAL(sgGetCurrentElement(QWebElement&)), this, SLOT(mpOnGetCurrentElement(QWebElement&)));
    @

    From the thread to class1 is:
    @ connect(insThread, SIGNAL(sgGetCurrentElement(QWebElement&)), this, SIGNAL(sgGetCurrentElement(QWebElement&)));
    @

    Whenever the second one is called, I received:

    bq. QObject::connect: Cannot queue arguments of type 'QWebElement&' (Make sure 'QWebElement&' is registered using qRegisterMetaType().)

    I have done some search about the issue and apparently I need to call qRegisterMetaType. I have learned that I need to add: @qRegisterMetaType<myElement>("myElement");@ in main. But I got the following error.

    bq. error: C2770: invalid explicit template argument(s) for 'int qRegisterMetaType(T *)'

    So, can anyone tell me how I should proceed? Thanks.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Please post the exact line you have used qRegisterMetaType in. Make sure QWebElement header is included in that file.

      (Z(:^

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dolevo
        wrote on last edited by
        #3

        [quote author="sierdzio" date="1396724797"]Please post the exact line you have used qRegisterMetaType in. Make sure QWebElement header is included in that file.[/quote]

        Hi sierdzio,

        Here is my main function at the moment,

        @int main(int argc, char *argv[])
        {
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
        qRegisterMetaType<myElement>("myElement");
        return a.exec();
        }@

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          Well, no surprise it does not work, then. 'myElement'is the thing you want to register with meta object system. In your case, that is 'QWebView'... you need to put that into the registration function.

          (Z(:^

          1 Reply Last reply
          0
          • D Offline
            D Offline
            dolevo
            wrote on last edited by
            #5

            [quote author="sierdzio" date="1396726404"]Well, no surprise it does not work, then. 'myElement'is the thing you want to register with meta object system. In your case, that is 'QWebView'... you need to put that into the registration function. [/quote]

            Let me repeat it:

            I add the following:

            @qRegisterMetaType<QWebElement>("myElement");@

            Then I changed QWebElement with myElement in my signals-slots like for example,

            @ connect(insTargetExtractor, SIGNAL(sgGetCurrentElement(myElement&)), this, SIGNAL(sgGetCurrentElement(myElement&)));
            @

            I also added:
            @typedef QWebElement myElement;@

            But now I get

            bq. QObject::connect: Cannot queue arguments of type 'myElement&'
            (Make sure 'myElement&' is registered using qRegisterMetaType().)

            if I use:
            @qRegisterMetaType<QWebElement&>("myElement");@
            It gives again the same error that I mentioned in my first post.

            1 Reply Last reply
            0
            • sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

              Use this:
              @
              qRegisterMetaType<QWebElement>("QWebElement");
              @

              And it should work, although I am not sure about references. If not, we will try some other solution.

              (Z(:^

              1 Reply Last reply
              0
              • D Offline
                D Offline
                dolevo
                wrote on last edited by
                #7

                [quote author="sierdzio" date="1396777110"]Use this:
                @
                qRegisterMetaType<QWebElement>("QWebElement");
                @

                And it should work, although I am not sure about references. If not, we will try some other solution.[/quote]

                Hi sierdzio,

                The main problem is actually signalling the address of a QWebElement. I already asked what to follow ideally in the following thread:
                "Your text to link here...":http://qt-project.org/forums/viewthread/41032/
                Perhaps you could have an idea.

                1 Reply Last reply
                0
                • sierdzioS Offline
                  sierdzioS Offline
                  sierdzio
                  Moderators
                  wrote on last edited by
                  #8

                  OK, let's jump around the threads a bit ;-)

                  (Z(:^

                  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