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. Template signals and multiple inheritance

Template signals and multiple inheritance

Scheduled Pinned Locked Moved Unsolved General and Desktop
16 Posts 4 Posters 1.6k Views
  • 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.
  • C Christian Ehrlicher
    10 May 2020, 17:07

    You can only paint in the paintEvent() of the widget.

    T Offline
    T Offline
    TrueNova
    wrote on 10 May 2020, 17:18 last edited by
    #7

    @Christian-Ehrlicher yes, I know, thank you, so what can I do to make implement this "use the second one as member" to my class for it to work, can you, please, give me a minimal of code of it?

    1 Reply Last reply
    0
    • C Online
      C Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 10 May 2020, 17:22 last edited by
      #8

      I can't and won't provide code since I don't know what you're doing and what you really want to achieve. I don't see a reason why someone would derive two times from QObject.

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

      T 1 Reply Last reply 10 May 2020, 17:32
      2
      • C Christian Ehrlicher
        10 May 2020, 17:22

        I can't and won't provide code since I don't know what you're doing and what you really want to achieve. I don't see a reason why someone would derive two times from QObject.

        T Offline
        T Offline
        TrueNova
        wrote on 10 May 2020, 17:32 last edited by TrueNova 5 Oct 2020, 17:33
        #9

        @Christian-Ehrlicher I need to make my Drawer class templated, as I know, QObject can't be so, that's why I divided it into my QObjectSubclass. Also, I need to inherit QWidget(parent) to my constructor, so I derrived my Drawer class from it too. That is why(I am pretty sure) I have this problem with connect() — "non-static member 'connect' has multiple-base class subobjects". Hope that will help you to understand my problem.

        1 Reply Last reply
        0
        • C Online
          C Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 10 May 2020, 17:41 last edited by
          #10

          @TrueNova said in Template signals and multiple inheritance:

          Hope that will help you to understand my problem.

          I understand your problem but you have to fix it another way - you can't derive two times from QObject (as already said) and templates + QObject won't work too so again - you have to find another solution.

          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
          3
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 10 May 2020, 18:03 last edited by
            #11

            Hi,

            You are explaining the problems you are having. Can you explain exactly what you are trying to achieve ?

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

            T 1 Reply Last reply 10 May 2020, 18:44
            2
            • S SGaist
              10 May 2020, 18:03

              Hi,

              You are explaining the problems you are having. Can you explain exactly what you are trying to achieve ?

              T Offline
              T Offline
              TrueNova
              wrote on 10 May 2020, 18:44 last edited by TrueNova 5 Oct 2020, 19:12
              #12

              @SGaist I have classes ierarchy like tree: Galaxy->Star->Planet->Satellite and Drawer class for each one of level. I am drawing, for example, a solar system(Sun and planets on their orbits), also, I want to draw planet system(planet and its satellites)of planets of this solar system. User is in the solar system with star in the center and planets are orbiting it, the user clicks on Earth, and now Earth appers on the Screen with Moon on the orbit. I have classes to show everything on the screen for each my type, and everything works well, but I need to be able to make everything with just one template class(as all of these classes are just almost nearly identical). As my class is template, I divided a QObject into another class and then inherited it in Drawer class(found this solution on Qt Forum), but also I need to be able to send signals from this class. Here I got error message from connect().
              If you are intend to help my seriously, cause this is a really hard problem, I guess, thank you. Then this may help you: my main goal is to send some signal with undefined type(Planet-, Star-, Satellite pointers) from my template class, when user clicks on orbit item(Planet, for example). Only thing that I need, is to catch this signal from MainWindow and than put the item(this Planet), that signal sent as the central system with its orbits(Satellites) on the screen, how to achieve this goal? Cause I think, there will be a lot of problems with emitting the templated type. Are there any possible way to do, what I need at all? Thank you.

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 10 May 2020, 19:19 last edited by
                #13

                What message do you want to send ?

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

                T 1 Reply Last reply 10 May 2020, 19:22
                0
                • S SGaist
                  10 May 2020, 19:19

                  What message do you want to send ?

                  T Offline
                  T Offline
                  TrueNova
                  wrote on 10 May 2020, 19:22 last edited by TrueNova 5 Oct 2020, 19:24
                  #14

                  @SGaist I want to do something like

                  template<typename T>
                  //something
                  signals:
                        sendItem( T* item);
                  connect(item, SIGNAL(clicked()), this, SlOT(itemClicked()));
                  itemClicked(){
                       emit sendItem(currentItem);
                  } 
                  
                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 10 May 2020, 19:52 last edited by
                    #15

                    Well, looks like you are currently trying to re-implement the graphics view framework. You really should consider using it.

                    On a side note, AFAIR, QObject based template class are currently not supported.

                    That said, you are trying to make your planetary objects and those related to them way too smart. If you want to keep your full custom approach, you should rather give them a render method that you will call from the "main" widget paintEvent rather than trying to make each of them a full blown widget.

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

                    T 1 Reply Last reply 10 May 2020, 20:15
                    2
                    • S SGaist
                      10 May 2020, 19:52

                      Well, looks like you are currently trying to re-implement the graphics view framework. You really should consider using it.

                      On a side note, AFAIR, QObject based template class are currently not supported.

                      That said, you are trying to make your planetary objects and those related to them way too smart. If you want to keep your full custom approach, you should rather give them a render method that you will call from the "main" widget paintEvent rather than trying to make each of them a full blown widget.

                      T Offline
                      T Offline
                      TrueNova
                      wrote on 10 May 2020, 20:15 last edited by
                      #16

                      @SGaist I think I understand your vision on this task. And one more time I will review graphics view framework, but somehow it seems too hard for me now. Thank you!

                      1 Reply Last reply
                      0

                      16/16

                      10 May 2020, 20:15

                      • Login

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