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. Setters and getters(for using pixmap of one class in another)
Forum Updated to NodeBB v4.3 + New Features

Setters and getters(for using pixmap of one class in another)

Scheduled Pinned Locked Moved General and Desktop
17 Posts 3 Posters 4.6k 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.
  • V Offline
    V Offline
    venkatesh
    wrote on last edited by
    #7

    Hi,

    Hey i found that the pixmap is empty.Why is this happening?. What am i doing wrong in the getter function?I think there is no problem in the items conversion as i could display the image in the original class which is setMovingImage(...)but not when i return it and access it in another class. I think some how the pixmap becomes null when i return it.

    1 Reply Last reply
    0
    • N Offline
      N Offline
      NicuPopescu
      wrote on last edited by
      #8

      have a look at "Implicit Data Sharing ":http://qt-project.org/doc/qt-5.0/qtcore/implicit-sharing.html

      even though it seems it should work you could try to use copy() instead of =operator which according to doc does not do a deep copy of pixmap data but just returns a reference untill a paint event occurs on the QPixmap object getting the reference

      1 Reply Last reply
      0
      • V Offline
        V Offline
        venkatesh
        wrote on last edited by
        #9

        Hey the link is not opening i don't know why. How can i use the copy()it needs some parameters which i don't use in my program. But i am puzzled why doesn't my pixmap contain the image and why is it null?..

        1 Reply Last reply
        0
        • V Offline
          V Offline
          venkatesh
          wrote on last edited by
          #10

          Hi,
          I am sure the problem is with the getData(); i think the other class which receives the pixmap is not receiving the data. Is the problem with the object created in overlayview?

          1 Reply Last reply
          0
          • V Offline
            V Offline
            venkatesh
            wrote on last edited by
            #11

            Hi,
            I found out that the object created @StationaryImageViewerObject@ has no information, as i didn't connect it with the @StationaryImageViewer@ though i have created the object i learnt i need to connect it with the StationaryImageViewer class, I am not so sure how to do it but. Would be privileged to have any of your guidances

            1 Reply Last reply
            0
            • N Offline
              N Offline
              NicuPopescu
              wrote on last edited by
              #12

              @ StationaryImageViewer StationaryImageViewerObject;@

              StationaryImageViewerObject is of type StationaryImageViewer ... how do you mean by connecting them?

              1 Reply Last reply
              0
              • V Offline
                V Offline
                venkatesh
                wrote on last edited by
                #13

                Hi,
                The problem is though i have created a object of the class. But i don't know how to make the Qt understand that i am pointing to the particular class.

                will this help

                @
                StationaryImageViewer StationaryImageViewer;
                @
                ?

                1 Reply Last reply
                0
                • N Offline
                  N Offline
                  NicuPopescu
                  wrote on last edited by
                  #14

                  and btw I have tested returning QPixmap from a function, passing as value or copying by = operator and all work just fine! you're doing something wrong elsewhere :)

                  1 Reply Last reply
                  0
                  • V Offline
                    V Offline
                    venkatesh
                    wrote on last edited by
                    #15

                    The problem is it doesn't know which class i am calling, though i am creating an object of the class. It's not getting connected to the class. I am not really sure why is this happening though :(

                    1 Reply Last reply
                    0
                    • N Offline
                      N Offline
                      NicuPopescu
                      wrote on last edited by
                      #16

                      bq. Hi,
                      The problem is though i have created a object of the class. But i don’t know how to make the Qt understand that i am pointing to the particular class.
                      will this help
                      StationaryImageViewer StationaryImageViewer;

                      ?

                      this phrase reveals more about your c++/qt understanding: I think you are still confusing a class type with its instance (in memory created object, static or dynamic) etc. ... better for you to review some c++ stuffs ... qt does not understand anything it's a framework, you could say the compiler does

                      1 Reply Last reply
                      0
                      • V Offline
                        V Offline
                        venkatesh
                        wrote on last edited by
                        #17

                        Hmmm, my problem here is how to exactly make the compiler know that i am pointing to the specific class?

                        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