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. Pass different classes to QSharedPointer?

Pass different classes to QSharedPointer?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 397 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.
  • C Offline
    C Offline
    Calicoder
    wrote on last edited by
    #1

    Howdy y'all, been reading the QT docs for the past hour and don't see if this is possible. I have 2 classes named Object1 and Object2, is it possible to pass each class to just 1 method with a QSharedPointer parameter?

    What I'm coding:

    void getData(QSharedPointer<???> object)  <-- ??? is where I'm trying to pass both Object1 first and when that completes pass Object2
    {
        ....
    }
    

    Thanks for any help and/or tips you provide. Much appreciated.

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

      Hi,

      You can make your function a templated function.

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

      C 2 Replies Last reply
      3
      • SGaistS SGaist

        Hi,

        You can make your function a templated function.

        C Offline
        C Offline
        Calicoder
        wrote on last edited by
        #3

        @SGaist Thanks for the reply. Never did that before, more reading I'm guessing.

        1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          You can make your function a templated function.

          C Offline
          C Offline
          Calicoder
          wrote on last edited by
          #4

          @SGaist Googling for some good examples currently. Any chance you have a sample code to share? Thanks

          1 Reply Last reply
          0
          • VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by VRonin
            #5
            template <class T>
            void getData(QSharedPointer<T> object)
            {
                ....
            }
            

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            1 Reply Last reply
            3
            • C Offline
              C Offline
              Calicoder
              wrote on last edited by
              #6

              Appreciate the help, thank you both. That worked

              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