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. Exchange images at the same position
Forum Updated to NodeBB v4.3 + New Features

Exchange images at the same position

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 1.0k 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.
  • J Offline
    J Offline
    Jeff
    wrote on last edited by
    #1

    Hi,

    in earlier days (VCL, C# Windows Forms) when I had to toggle between two images at the same location in a window I placed those two images at the very same location and toggled their visibility.
    How would I achieve such behaviour with Qt?

    I just started programming with Qt and I cannot find any simple way :-( When I have a label with a pixmap, I cannot put two of them to the same position. At least the layout system in Qt Designer doesn't seem to allow this.
    Even if I would think about resetting the pixmap (what would be the best way then?) I wonder how one can use overlapping elements.

    Thanks
    Jeff

    1 Reply Last reply
    0
    • M Offline
      M Offline
      matze42
      wrote on last edited by
      #2

      Have a look at QStackedWidget

      1 Reply Last reply
      0
      • M Offline
        M Offline
        maximus
        wrote on last edited by maximus
        #3

        You could use
        QLabel.setPixmap(..)
        And just use one label, no overlapping

        If you want overlapping, a QGridLayout let you to have element on top of another.
        Just insert them in the same row, column and toggle visibility of the one you need

        Good luck!


        Free Indoor Cycling Software - https://maximumtrainer.com

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

          Hi,

          For "overlapping" rather than the QGridLayout, a QStackedLayout or as suggested by by @matze42 a QStackedWidget it the way to go.

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

          1 Reply Last reply
          0
          • J Offline
            J Offline
            Jeff
            wrote on last edited by
            #5

            Thank you all - QStackedWidget helps!

            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