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. [Solved] qRegisterMetaType?
Forum Updated to NodeBB v4.3 + New Features

[Solved] qRegisterMetaType?

Scheduled Pinned Locked Moved General and Desktop
12 Posts 3 Posters 8.3k 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.
  • M Offline
    M Offline
    MohammadReza
    wrote on last edited by
    #1

    Hello friends.
    im beginner in Qt & im creating an application with winpcap. During running the application, i got an strange result!!!
    something like this:

    " 5.2.1-x86-msvc2012-opengl\include\QtCore/qmetatype.hrmalizedMetaTypeizedMetaTypeo
    gl\include\QtCore/qmetatype.he name, please call qRegisterMetaType instead.a not normalized type name, please call qRegisterMetaType instead. "

    The result must be an IP address not the above result!!!
    in my codes, i used a thread to capture the packets & used this signal & slot:

    @
    connect(tCapture, SIGNAL(SendData(const u_char *)), this, SLOT(ReceiveData(const u_char *)));
    @

    Thanks a lot.
    Ya Ali.

    1 Reply Last reply
    0
    • JohanSoloJ Offline
      JohanSoloJ Offline
      JohanSolo
      wrote on last edited by JohanSolo
      #2

      You can safely remove the const, even if the real signature of SendData and ReceiveData is const u_char*.
      Since you're passing the parameter via a pointer you don't need to register the type AFAIK.

      `They did not know it was impossible, so they did it.'
      -- Mark Twain

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MohammadReza
        wrote on last edited by
        #3

        Thanks dear Johan Solo.
        i removed the const but the starnge results are still there!

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

          Not sure if I can help but for the sake of clarity, you get this as a compilation error?

          Could you please post the exact line the error refers to and the complete error message? (the post you have cuts some lines in the middle).

          "Roads? Where we're going, we don't need roads."

          1 Reply Last reply
          0
          • M Offline
            M Offline
            MohammadReza
            wrote on last edited by
            #5

            Hello frankiefrank.
            this is the whole of my project:
            http://rainbow7.persiangig.com/Qt/PacketCapturing.rar/download
            (click the orange picture that is written download in order to download this file)

            I thinks this is a logical error.
            In application output it shows something like this:

            QObject::connect: Cannot queue arguments of type 'QList<QPersistentModelIndex>'
            (Make sure 'QList<QPersistentModelIndex>' is registered using qRegisterMetaType().)
            QObject::connect: Cannot queue arguments of type 'QVector<int>'
            (Make sure 'QVector<int>' is registered using qRegisterMetaType().)

            As you said, the error i mentioned in my first post is not complete, because the application doesn`t show

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

              I can't really run your code without the pcap.h file.

              From a first look, you don't emit your signal correctly. It should be:
              @
              emit SendData(packetData);
              @

              Also, I'm not sure if you should even call qRegisterMetaType there, the error you get seem to be not relevant to the parameters we actually see.

              "Roads? Where we're going, we don't need roads."

              1 Reply Last reply
              0
              • M Offline
                M Offline
                MohammadReza
                wrote on last edited by
                #7

                Thanks for your response.
                i corrected emit SendData(packetData); but the error is still there.

                I searched & some users of some forums said you shouldnt pass reference parameter in signal & slot. Im a little confused!

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

                  For your connect() call, add a boolean variable to store the return value of the connect call (i.e. bool success = connect(....) ).

                  Then run with debug, make a break point on the connect line.

                  Make sure that before you pass that line, your Application Output doesn't show any errors. Then step through the line and assure that you really get that error about QList<QPersistentModelIndex> only then. If it appeared even before that - then it's from somewhere else in the code you are compiling/running and has nothing to do with this specific connect.

                  "Roads? Where we're going, we don't need roads."

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

                    i wrote:
                    @
                    bool checked = connect(tCapture, SIGNAL(SendData(const u_char *)), this, SLOT(ReceiveData(const u_char *)));
                    @

                    checked --> true

                    i think The mentioned error appear when data transfer from tCapture thread to mainwindow class. but not sure.

                    1 Reply Last reply
                    0
                    • F Offline
                      F Offline
                      frankiefrank
                      wrote on last edited by
                      #10

                      OK, it's a bit difficult to help out if you don't localize the error first through the debugging.

                      In the code that you sent me the connect statement contained Qt::DirectConnection - this doesn't make sense since you will be emitting the signal from a different thread.

                      Again, try commenting out the qRegisterMetaType call and try to localize the error (or is this a warning only?) through debugging.

                      For example, put a breakpoint inside your slot to see that you actually get to that code, then keep stepping through to see at which point that warning/error appears.

                      "Roads? Where we're going, we don't need roads."

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

                        frankie frank.
                        I think the problem is solved.
                        as you said not relate to connect. That`s because of my slot function.
                        i had written something like this:
                        QString a = ih->daddr.byte4;
                        newRow = new QStandardItem(a);

                        it means i set u_char to Qstring directly! this was my wrong!

                        thanks to you because of your help.
                        (excuse me if my english writting was not good)

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

                          No worries :) Glad to have helped.

                          Make sure you edit your original post and add [SOLVED] to the post title.

                          "Roads? Where we're going, we don't need roads."

                          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