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. How to overlap an image with a label
Forum Updated to NodeBB v4.3 + New Features

How to overlap an image with a label

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 621 Views 3 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.
  • F Offline
    F Offline
    FLmrk3ICK
    wrote on last edited by
    #1

    Is it possible to overlap an image inside a layout with a label? I have a window with 2 layouts (top and bottom), the top layout has an image and I want to overlap this image with some little labels, but I can't.

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

      Hi and welcome to devnet,

      Depending on what your goal is, you can render the image on the widget that you set the layout on.

      In any case, you have to provide more details about what you want to get at the end.

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

      F 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        Depending on what your goal is, you can render the image on the widget that you set the layout on.

        In any case, you have to provide more details about what you want to get at the end.

        F Offline
        F Offline
        FLmrk3ICK
        wrote on last edited by
        #3

        @SGaist
        I have an image of an electronic diagram inside a label that is in a layout, I want to position labels overlapping this image of the diagram (the objective is to leave the labels on top of each valve and sensor)

        Pl45m4P 1 Reply Last reply
        0
        • F FLmrk3ICK

          @SGaist
          I have an image of an electronic diagram inside a label that is in a layout, I want to position labels overlapping this image of the diagram (the objective is to leave the labels on top of each valve and sensor)

          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote on last edited by Pl45m4
          #4

          @FLmrk3ICK

          You can simply position the parentless layoutless labels using fixed coordinates.
          Maybe you need some kind of anchor to lock them in place when the rest resizes or moves, so that the labels are still where they should be


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          jeremy_kJ F 2 Replies Last reply
          0
          • Pl45m4P Pl45m4

            @FLmrk3ICK

            You can simply position the parentless layoutless labels using fixed coordinates.
            Maybe you need some kind of anchor to lock them in place when the rest resizes or moves, so that the labels are still where they should be

            jeremy_kJ Offline
            jeremy_kJ Offline
            jeremy_k
            wrote on last edited by
            #5

            @Pl45m4 said in How to overlap an image with a label:

            @FLmrk3ICK

            You can simply position the parentless labels using fixed coordinates.

            Is parentless a typo? The overlaying labels need to have a parent to avoid turning them into windows. The easiest solution I can think of is to parent the text labels to the image label. This can be done with a layout set on the background label, or through direct positioning.

            QLabel background("___\n___\n___");
            QLabel foreground("X", &background);
            foreground.move(10, 10);
            QHBoxLayout layout(&background);
            QLabel layoutForeground("0");
            layout.addWidget(&layoutForeground);
            background.show();
            

            It may be worth considering doing this with the graphics view framework instead.

            Asking a question about code? http://eel.is/iso-c++/testcase/

            Pl45m4P 1 Reply Last reply
            2
            • jeremy_kJ jeremy_k

              @Pl45m4 said in How to overlap an image with a label:

              @FLmrk3ICK

              You can simply position the parentless labels using fixed coordinates.

              Is parentless a typo? The overlaying labels need to have a parent to avoid turning them into windows. The easiest solution I can think of is to parent the text labels to the image label. This can be done with a layout set on the background label, or through direct positioning.

              QLabel background("___\n___\n___");
              QLabel foreground("X", &background);
              foreground.move(10, 10);
              QHBoxLayout layout(&background);
              QLabel layoutForeground("0");
              layout.addWidget(&layoutForeground);
              background.show();
              

              It may be worth considering doing this with the graphics view framework instead.

              Pl45m4P Offline
              Pl45m4P Offline
              Pl45m4
              wrote on last edited by
              #6

              @jeremy_k said in How to overlap an image with a label:

              Is parentless a typo? The overlaying labels need to have a parent to avoid turning them into windows.

              Ah... somehow I was thinking "not in a layout" and wrote "no parent" :D
              Yeah, better add the widget, on which they are hovering as parent, so they "inherit" its coordinate system.


              If debugging is the process of removing software bugs, then programming must be the process of putting them in.

              ~E. W. Dijkstra

              1 Reply Last reply
              0
              • Pl45m4P Pl45m4

                @FLmrk3ICK

                You can simply position the parentless layoutless labels using fixed coordinates.
                Maybe you need some kind of anchor to lock them in place when the rest resizes or moves, so that the labels are still where they should be

                F Offline
                F Offline
                FLmrk3ICK
                wrote on last edited by
                #7

                @Pl45m4 I used labels with fixed coordinates and its worked, what do you mean by anchor lock? Its an expression? I’m not native speaker.

                Im really getting trouble to adjust the labels coordinates and sizes. Im trying to make simple rule of three based on size proportions of the screen

                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