Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTest Error
Qt 6.12 LTS is out! See what's new in the release blog

QTest Error

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 1.1k 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.
  • I Offline
    I Offline
    ikuris
    wrote on last edited by
    #1

    I am trying to learn unit testing but I have some troubles,
    MyTest{
    public:
    constructorsand destructor;
    private slots:
    initTestCase()
    init()
    cleanup()
    cleanupTestCase()
    void mytest();
    void mytest_data();
    };
    After I addded QTest::addColumn and newRow() in mytest_data() I am getting error : "Type is not registered, please use the Q_DECLARE_METATYPE macro to make it know to Qt's meta-object system" . So I added Q_DECLARE_METATYPE(MyTest) in the end of the header file and now I am getting Error : Code 1 Description moc (path..\bin\moc.exe).

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

      Hi,

      Please show the complete code.
      The is likely related to the types you are using in one or more of your columns.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      I 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Please show the complete code.
        The is likely related to the types you are using in one or more of your columns.

        I Offline
        I Offline
        ikuris
        wrote on last edited by
        #3

        @SGaist
        I am using QStringlist, and some custom structures as my column types.( addColumn<QStringList>("label") ...) . Do I need to include Q_DECLARE_METATYPE for them ?

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

          Again, please show the complete code.

          You should also add the relevant build log.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          I 1 Reply Last reply
          0
          • SGaistS SGaist

            Again, please show the complete code.

            You should also add the relevant build log.

            I Offline
            I Offline
            ikuris
            wrote on last edited by
            #5

            @SGaist
            Problem is solved after I added Q_DECLARE_METATYPE for my custom structures. Thank you

            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
            • Unsolved