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. How to build real template class?
Qt 6.11 is out! See what's new in the release blog

How to build real template class?

Scheduled Pinned Locked Moved Unsolved General and Desktop
26 Posts 11 Posters 11.7k Views 6 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.
  • Axel SpoerlA Offline
    Axel SpoerlA Offline
    Axel Spoerl
    Moderators
    wrote on last edited by
    #2

    @AnneRanch
    A template class is correct if it compiles, and wrong if it doesn't.
    A class is either a template class, or it's not.
    I don't understand what you mean by "fake" and "real".

    The only limitation in Qt is that you can't use Q_OBJECT in a template class.
    But the template class can inherit from a class, that does have the Q_OBJECT macro.

    #include <QObject>
    
    class TEST : public QObject
    {
        Q_OBJECT
    public:
        explicit TEST_Template(QObject *parent = nullptr);
    
    signals:
        void aSignal(int number);
    };
    
    template <typename T>
    class TEST_Template : public TEST
    {
        ...
    };
    

    Looks as I poked stick into hornets nest - all kinds of "stuff" I took for granted so far.

    Don't worry, no hornets in this neighbourhood.

    Software Engineer
    The Qt Company, Oslo

    1 Reply Last reply
    1
    • A Offline
      A Offline
      Asperamanca
      wrote on last edited by
      #3

      The important question is: What are you trying to achieve?
      I struggle to see a compelling use case for a templated QObject, but I might be missing something...

      1 Reply Last reply
      2
      • A Offline
        A Offline
        Anonymous_Banned275
        wrote on last edited by
        #4

        I do not agree with your opinion : What are you trying to achieve?
        My missed point is - Qt documentation call the result of their process of building a class a " template". It is NOT template TYPE by definition, it is Qt miss use of a term.
        I have no illusion that pointing that out will "achieve " anything. Qt is pushing its own terminology and continue to do so irregardless of me , a user , opinion. They are the experts , in their opinions / view.
        My only "achievement' could be to make others users of Qt aware. That is about all I could hope for.

        Axel SpoerlA 1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #5

          It is creating a template for a class derived from QObject, not a template class. You are mixing different stuff.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          4
          • A Offline
            A Offline
            Asperamanca
            wrote on last edited by
            #6

            Could you link the relevant documentation page?

            1 Reply Last reply
            0
            • A Offline
              A Offline
              Anonymous_Banned275
              wrote on last edited by
              #7

              https://wiki.qt.io/Qt_for_Beginners

              FeRDNYCF 1 Reply Last reply
              0
              • A Offline
                A Offline
                Asperamanca
                wrote on last edited by
                #8

                "Template" in this context is simply an English word in the same way as you may have a "Template for a presentation", i.e. something generic to help you get started, from which you can then customize what you want.

                1 Reply Last reply
                7
                • A Offline
                  A Offline
                  Anonymous_Banned275
                  wrote on last edited by
                  #9

                  I disagree , especially when it is " for beginners" .
                  Cheers

                  A 1 Reply Last reply
                  0
                  • A Anonymous_Banned275

                    I do not agree with your opinion : What are you trying to achieve?
                    My missed point is - Qt documentation call the result of their process of building a class a " template". It is NOT template TYPE by definition, it is Qt miss use of a term.
                    I have no illusion that pointing that out will "achieve " anything. Qt is pushing its own terminology and continue to do so irregardless of me , a user , opinion. They are the experts , in their opinions / view.
                    My only "achievement' could be to make others users of Qt aware. That is about all I could hope for.

                    Axel SpoerlA Offline
                    Axel SpoerlA Offline
                    Axel Spoerl
                    Moderators
                    wrote on last edited by
                    #10

                    It is NOT template TYPE by definition, it is Qt miss use of a term.

                    That's simply wrong, @AnneRanch.
                    The misunderstanding is entirely on your side.

                    As @Asperamanca indicated, the term "template" is standard English vocabulary. If you reserve it exclusively for what is a template in C++, you limit your own vocabulary.

                    The documentation page you referred, is truly outdated, but it doesn't contain anything wrong. It uses word "template" in two different contexts:

                    • TEMPLATE directive of qmake
                    • creating a class definition, following a template (as @Asperamanca already explained)

                    The page does not contain any mention of the term "template" in C++ code. That makes the context pretty obvious for any C++ programmer, beginners included.

                    Software Engineer
                    The Qt Company, Oslo

                    1 Reply Last reply
                    4
                    • A Anonymous_Banned275

                      I disagree , especially when it is " for beginners" .
                      Cheers

                      A Offline
                      A Offline
                      Asperamanca
                      wrote on last edited by
                      #11

                      @AnneRanch said in How to build real template class?:

                      I disagree , especially when it is " for beginners" .
                      Cheers

                      I agree that the conflict of terms here is a bit unfortunate. Then again, I cannot come up with a more fitting term for "template" in this context. If you have a better idea, you can also write documentation suggestion to bugreports.qt.io

                      Pl45m4P 1 Reply Last reply
                      2
                      • A Asperamanca

                        @AnneRanch said in How to build real template class?:

                        I disagree , especially when it is " for beginners" .
                        Cheers

                        I agree that the conflict of terms here is a bit unfortunate. Then again, I cannot come up with a more fitting term for "template" in this context. If you have a better idea, you can also write documentation suggestion to bugreports.qt.io

                        Pl45m4P Offline
                        Pl45m4P Offline
                        Pl45m4
                        wrote on last edited by
                        #12

                        @Asperamanca said in How to build real template class?:

                        I cannot come up with a more fitting term for "template" in this context

                        I can think of another term (don't know if better or not), but I'm not allowed to comment :)))
                        The first part is a color, the second part of the word is what a certain I/O device does :)))


                        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                        ~E. W. Dijkstra

                        R 1 Reply Last reply
                        0
                        • Pl45m4P Pl45m4

                          @Asperamanca said in How to build real template class?:

                          I cannot come up with a more fitting term for "template" in this context

                          I can think of another term (don't know if better or not), but I'm not allowed to comment :)))
                          The first part is a color, the second part of the word is what a certain I/O device does :)))

                          R Offline
                          R Offline
                          Redman
                          wrote on last edited by
                          #13

                          @Pl45m4 yellow fax

                          Pl45m4P Axel SpoerlA 2 Replies Last reply
                          1
                          • R Redman

                            @Pl45m4 yellow fax

                            Pl45m4P Offline
                            Pl45m4P Offline
                            Pl45m4
                            wrote on last edited by
                            #14

                            @Redman said in How to build real template class?:

                            yellow fax

                            Yep. That's it :))
                            You're good :D


                            If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                            ~E. W. Dijkstra

                            1 Reply Last reply
                            0
                            • R Redman

                              @Pl45m4 yellow fax

                              Axel SpoerlA Offline
                              Axel SpoerlA Offline
                              Axel Spoerl
                              Moderators
                              wrote on last edited by
                              #15

                              @Redman
                              C'mon, ever seen a yellow fax?
                              He meant orange jam, obviously.

                              Software Engineer
                              The Qt Company, Oslo

                              Pl45m4P 1 Reply Last reply
                              1
                              • Axel SpoerlA Axel Spoerl

                                @Redman
                                C'mon, ever seen a yellow fax?
                                He meant orange jam, obviously.

                                Pl45m4P Offline
                                Pl45m4P Offline
                                Pl45m4
                                wrote on last edited by
                                #16

                                @Axel-Spoerl said in How to build real template class?:

                                He meant orange jam, obviously.

                                Actually I was referring to commonly used term "reddisplay".
                                ... but I agreed to @Redman so he wouldn't feel bad :)))


                                If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                                ~E. W. Dijkstra

                                1 Reply Last reply
                                2
                                • jsulmJ Offline
                                  jsulmJ Offline
                                  jsulm
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #17

                                  bluescreen :-)

                                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  Pl45m4P 1 Reply Last reply
                                  3
                                  • jsulmJ jsulm

                                    bluescreen :-)

                                    Pl45m4P Offline
                                    Pl45m4P Offline
                                    Pl45m4
                                    wrote on last edited by
                                    #18

                                    @jsulm said in How to build real template class?:

                                    bluescreen :-)

                                    That's what you get when using yellow fax wrong :))


                                    If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                                    ~E. W. Dijkstra

                                    1 Reply Last reply
                                    1
                                    • Axel SpoerlA Offline
                                      Axel SpoerlA Offline
                                      Axel Spoerl
                                      Moderators
                                      wrote on last edited by Axel Spoerl
                                      #19

                                      I got it: Black Label!
                                      Edit: Green Card.

                                      Software Engineer
                                      The Qt Company, Oslo

                                      1 Reply Last reply
                                      0
                                      • J.HilkJ Offline
                                        J.HilkJ Offline
                                        J.Hilk
                                        Moderators
                                        wrote on last edited by
                                        #20

                                        This took me exceedingly long to get omfg.


                                        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                                        Q: What's that?
                                        A: It's blue light.
                                        Q: What does it do?
                                        A: It turns blue.

                                        1 Reply Last reply
                                        0
                                        • A Anonymous_Banned275

                                          https://wiki.qt.io/Qt_for_Beginners

                                          FeRDNYCF Offline
                                          FeRDNYCF Offline
                                          FeRDNYC
                                          wrote on last edited by
                                          #21

                                          @AnneRanch said in How to build real template class?:

                                          https://wiki.qt.io/Qt_for_Beginners

                                          The issue brought up here is far from the most objectionable thing on that page. I mean, have you seen THIS nonsense?

                                          Qt (pronounced as "cute", not "cu-tee")

                                          Not just no, but HELL no!

                                          Pl45m4P S 2 Replies 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