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. Trying to construct an instance of an invalid type, type id: 145

Trying to construct an instance of an invalid type, type id: 145

Scheduled Pinned Locked Moved General and Desktop
9 Posts 3 Posters 10.4k 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.
  • S Offline
    S Offline
    smita30apr
    wrote on last edited by
    #1

    Hi,

    I am getting these messages as warnings in my Desktop Application using Qt 5:

    Trying to construct an instance of an invalid type, type id: 145
    Trying to construct an instance of an invalid type, type id: 145
    Trying to construct an instance of an invalid type, type id: 145
    Trying to construct an instance of an invalid type, type id: 145

    The gui runs fine. Its just that I get these warnings. What could be wrong?

    Thanks :)

    1 Reply Last reply
    0
    • L Offline
      L Offline
      leon.anavi
      wrote on last edited by
      #2

      Could you please provide the source code which generates this warning? I guess that you might be using QVariant in an appropriate way.

      http://anavi.org/

      1 Reply Last reply
      1
      • S Offline
        S Offline
        smita30apr
        wrote on last edited by
        #3

        Thank you for your reply!

        QVariant is being used in many places in the code actually. So What do you mean by using QVariant unappropriately? I can search for all existing QVariants, but how to see if its used correctly. Do you have any idea about the significance of "145" id, that its generating.

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

          Hi,

          Did you:

          • declared your type with Q_DECLARE_METATYPE ?
          • call qRegisterMetaTypeStreamOperators and implement both stream operators ?

          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
          0
          • S Offline
            S Offline
            smita30apr
            wrote on last edited by
            #5

            Yes I have. Declared my new type with Q_DECLARE_METATYPE and used qRegisterMetaTypeStreamOperators

            1 Reply Last reply
            0
            • S Offline
              S Offline
              smita30apr
              wrote on last edited by
              #6

              I tried to debug, seems its happening with a QTreeView. My code is below

              @
              QAction *show_user_action = QAction("User");
              show_user_action->setCheckable(true);
              show_user_action->setChecked(show_user); connect(show_user_action,SIGNAL(triggered(bool)),
              m_directory_view,SLOT(show_column(bool)));
              @

              On Calling:
              show_user_action->trigger();
              those warnings are displayed.

              the slot code is:

              @
              show_column(bool show) {

              QAction *action = qobject_cast< QAction *>(QObject::sender());
              QString action_name = action->get_name();
              m_filter_model->set_column_visible(action_name,show);
              m_directory_view->header()->resizeSections(QHeaderView::ResizeToContents);
              }
              @

              The last line m_directory_view->header()->resizeSections(QHeaderView::ResizeToContents); generates the warning.

              Any clue here?

              [edit: added missing coding tags @ SGaist]

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

                Well… It looks unrelated.

                Do you have any QVariant stuff in your code ? QSettings ?

                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
                0
                • S Offline
                  S Offline
                  smita30apr
                  wrote on last edited by
                  #8

                  Well, I added a breakpoint at m_directory_view->header()->resizeSections(QHeaderView::ResizeToContents);
                  and once it is executed it generates that warning. Its strange though.
                  But I use both QVariant and QSettings. Actually line 3 at the above code:
                  show_user_action->setChecked(show_user); <- show_user is a QVariant stored in QSettings.

                  What can I check for here?

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

                    Are you storing one of your custom class in QSettings ?

                    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
                    0

                    • Login

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