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. :-1: erreur : [debug/moc_configtreerow.cpp] Error 1
Forum Updated to NodeBB v4.3 + New Features

:-1: erreur : [debug/moc_configtreerow.cpp] Error 1

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 498 Views 2 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.
  • Z Offline
    Z Offline
    Zunneh
    wrote on last edited by
    #1

    Hello guys, i'm working on project which contains class named CONFIGTREEROW that inherits from QTreeWidgetItem, the problem is when i enable the public slots (which contain 3 fonctions and try to build, i have this problem
    config.png

    and when i remove public slots, i can build it, i don't know where is the problem ?
    faa240fd-72f0-434d-8850-9d089168b0d4-image.png

    Thanks

    my english is average, please use simple words and try to be the most explicit, thank you

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

      Hi,

      QTreeWidgetItem is not QObject based and if it was, you are missing the Q_OBJECT macro.

      Just because a class starts with Q doesn't mean it derives from QObject. A typical example is QString. Same goes for the convenience view classes and their custom item. There's no sense in having the overhead of QObject for thing that should store only data.

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

      Z 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        QTreeWidgetItem is not QObject based and if it was, you are missing the Q_OBJECT macro.

        Just because a class starts with Q doesn't mean it derives from QObject. A typical example is QString. Same goes for the convenience view classes and their custom item. There's no sense in having the overhead of QObject for thing that should store only data.

        Z Offline
        Z Offline
        Zunneh
        wrote on last edited by
        #3

        @SGaist i added it and always same problem, maybe i should do multiple inherits from QTreeWidgetItem and QObject ?

        1fc283cb-316e-4a0f-b436-7105bed25b87-image.png

        my english is average, please use simple words and try to be the most explicit, thank you

        JonBJ 1 Reply Last reply
        0
        • Z Zunneh

          @SGaist i added it and always same problem, maybe i should do multiple inherits from QTreeWidgetItem and QObject ?

          1fc283cb-316e-4a0f-b436-7105bed25b87-image.png

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @Zunneh
          You can't just add Q_OBJECT macro into a (non-QObject) class. That doesn't make it inherit from QObject. Yes, you would have to (multiple) inherit to add QObject, if that is what you want to do.

          However, I would think that what @SGaist has said about "QTreeWidgetItem is not QObject based" might make you consider whether you really want this? If the class is not already written into a project, maybe you should think again about adding QObject/signals/slots into the class you are deriving? Clearly QTreeWidgetItem leaves those to the parenting QTreeWidget, so perhaps your sub-class ought follow that principle too?

          Z 1 Reply Last reply
          2
          • JonBJ JonB

            @Zunneh
            You can't just add Q_OBJECT macro into a (non-QObject) class. That doesn't make it inherit from QObject. Yes, you would have to (multiple) inherit to add QObject, if that is what you want to do.

            However, I would think that what @SGaist has said about "QTreeWidgetItem is not QObject based" might make you consider whether you really want this? If the class is not already written into a project, maybe you should think again about adding QObject/signals/slots into the class you are deriving? Clearly QTreeWidgetItem leaves those to the parenting QTreeWidget, so perhaps your sub-class ought follow that principle too?

            Z Offline
            Z Offline
            Zunneh
            wrote on last edited by
            #5

            @JonB said in :-1: erreur : [debug/moc_configtreerow.cpp] Error 1:

            so perhaps your sub-class ought follow that principle too?

            Yes, i understand now, i have another question, when doing multiple inherits, for example QObject had a method name parent() and QTreeWidgetItem had the same Method, to call the method of QTreeWidgetItem in my program i have to use QTreeWidgtItem::parent() ?
            Thanks

            my english is average, please use simple words and try to be the most explicit, thank you

            JonBJ 1 Reply Last reply
            0
            • Z Zunneh

              @JonB said in :-1: erreur : [debug/moc_configtreerow.cpp] Error 1:

              so perhaps your sub-class ought follow that principle too?

              Yes, i understand now, i have another question, when doing multiple inherits, for example QObject had a method name parent() and QTreeWidgetItem had the same Method, to call the method of QTreeWidgetItem in my program i have to use QTreeWidgtItem::parent() ?
              Thanks

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @Zunneh
              Yes to your question about needing to disambiguate/resolve same-name in multi-inheritance via class::, like QTreeWidgetItem::parent().

              Of course, if you redesign like we said this would not be an issue :) And if you are going to redesign, the sooner you change code instead of continuing as now the better, instead of spending time on this sort of issue!

              1 Reply Last reply
              2

              • Login

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