Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

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

    General and Desktop
    3
    9
    8866
    Loading More Posts
    • 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
      smita30apr last edited by

      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 Reply Quote 0
      • L
        leon.anavi last edited by

        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 Reply Quote 1
        • S
          smita30apr last edited by

          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 Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            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 Reply Quote 0
            • S
              smita30apr last edited by

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

              1 Reply Last reply Reply Quote 0
              • S
                smita30apr last edited by

                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 Reply Quote 0
                • SGaist
                  SGaist Lifetime Qt Champion last edited by

                  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 Reply Quote 0
                  • S
                    smita30apr last edited by

                    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 Reply Quote 0
                    • SGaist
                      SGaist Lifetime Qt Champion last edited by

                      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 Reply Quote 0
                      • First post
                        Last post