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. When QGraphicsItem meets heritage
Forum Updated to NodeBB v4.3 + New Features

When QGraphicsItem meets heritage

Scheduled Pinned Locked Moved Solved General and Desktop
heritageqgraphicsitem
6 Posts 4 Posters 1.8k 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.
  • W Offline
    W Offline
    Walux
    wrote on last edited by Walux
    #1

    Hi Qt community ,

    I wouldn't call it an issue but ,

    I have a subclassed QGraphicsItem that's inherited by 3 classes .

    I want the 3 inheriting classes to have in common the same advance() method ( without copy pasting the code in the advance() method of each one of them ofcourse :b) .
    I tried writing my code in the advance() method of the mother class but it didn't work .

    Any ideas ?
    I'll be grateful ;)

    Taking things from beginning to end : That's my entertainment !

    1 Reply Last reply
    0
    • FlotisableF Offline
      FlotisableF Offline
      Flotisable
      wrote on last edited by
      #2

      Maybe you should talk about how the 3 classes inherit the parent or how you use the advance() method

      I think it will be more clear on the problem and others can help you

      Sorry for bad english

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

        And it would help to know what did not work, else we can only guess.

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

        1 Reply Last reply
        1
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          In addition what other said already, you may be talking about GraphicsItem->A. A->B, A->C, A-D. Hope this is the inheritance you are talking about. This should go with Simple C++ method called advance() in your class A. you can provide the default implementation in A. Or you can make it virtual in A and implement it. If you want change the implementation change in B, C and D.

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          W 1 Reply Last reply
          4
          • dheerendraD dheerendra

            In addition what other said already, you may be talking about GraphicsItem->A. A->B, A->C, A-D. Hope this is the inheritance you are talking about. This should go with Simple C++ method called advance() in your class A. you can provide the default implementation in A. Or you can make it virtual in A and implement it. If you want change the implementation change in B, C and D.

            W Offline
            W Offline
            Walux
            wrote on last edited by Walux
            #5

            @dheerendra

            Yes , the heritage is like you said : A-> B , A-> C , A-> D .
            And i mentionned that writing the code i want to be executed by the three classes in the mother Class "A" doesn't work .
            But since , u confirmed that , does the problem exist because I didn't declare the mother advance() method virtual ?

            Best regards :)

            Taking things from beginning to end : That's my entertainment !

            1 Reply Last reply
            0
            • W Offline
              W Offline
              Walux
              wrote on last edited by
              #6

              Yep, it's fixed.

              Topic->setAsSolved(true)

              Taking things from beginning to end : That's my entertainment !

              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