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 place radiobuttons inside a map through PyQt5?
Forum Update on Monday, May 27th 2025

How to place radiobuttons inside a map through PyQt5?

Scheduled Pinned Locked Moved Unsolved General and Desktop
pyqt5python3qt designer
7 Posts 4 Posters 448 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.
  • R Offline
    R Offline
    Rangerguy128
    wrote on last edited by
    #1

    I have a window that has a label in the center that contains a certain part of a map. I'm planning to add radio buttons in certain parts of it do that when clicked on, it'll show small information about that place. Howecer, ai'm not sure how I can set it up. I'm using QT Designer to design the window and the language of my choice is Python 3.11.

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

      Hi,

      If the map is a simple image, you can place the QRadioButton on top of it not placing them in a layout. However, you will have to manual move them upon window resize.

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

      R 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        If the map is a simple image, you can place the QRadioButton on top of it not placing them in a layout. However, you will have to manual move them upon window resize.

        R Offline
        R Offline
        Rangerguy128
        wrote on last edited by
        #3

        @SGaist I see. I'm using a QLabel to place the buttons, like this (placed inside a QStackedWidget): 01a5aa9c-6901-40c5-a20c-0c8e47772df2-image.png

        I tried inserting the buttons but they always get placed under the label.

        JonBJ 1 Reply Last reply
        0
        • R Rangerguy128

          @SGaist I see. I'm using a QLabel to place the buttons, like this (placed inside a QStackedWidget): 01a5aa9c-6901-40c5-a20c-0c8e47772df2-image.png

          I tried inserting the buttons but they always get placed under the label.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @Rangerguy128
          If you add the buttons with the label as the parent you are saying they appear under the label?
          OIC, you mean below the image on the label? Did you try moving their coordinates?

          R 1 Reply Last reply
          0
          • JonBJ JonB

            @Rangerguy128
            If you add the buttons with the label as the parent you are saying they appear under the label?
            OIC, you mean below the image on the label? Did you try moving their coordinates?

            R Offline
            R Offline
            Rangerguy128
            wrote on last edited by
            #5

            @JonB Below the image. I want to place them over the map image but QT designer automatically places them below the QLabel (not under the label, of course).

            JonBJ 1 Reply Last reply
            0
            • R Rangerguy128

              @JonB Below the image. I want to place them over the map image but QT designer automatically places them below the QLabel (not under the label, of course).

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @Rangerguy128
              Your label does not have a layout, right? You add the radiobutton directly onto the label? Then I know you can use QWidget::move() in code. Does Qt Designer have something like an x and y position property for widgets?

              1 Reply Last reply
              0
              • C Offline
                C Offline
                ChrisW67
                wrote on last edited by
                #7

                You have placed the radio buttons in the layout of the widget that contains the QLabel image. Widgets in a layout are positioned at run time by the layout logic and will not overlap. If you want to position a QRadiobutton visibly on top of another widget (i.e on top of the QLabel image of Puerto Rico beach) then:

                • The parent widget of the QRadioButtons should be the QLabel. This ensures the on-top-of element but cannot easily be achieved in Designer because it does not consider QLabel a container.
                • The QRadioButtons cannot be in a layout.
                • Positioning the buttons is absolute and you are responsible for adjusting it if the label is resized.

                It can be achieved with a bit of code. Either:

                • Put the QRadioButtions into the Designer UI layout then, in the form widget code after calling setupUI(), change their parentage and position (which will be relative to the label content area).
                • Leave the QRadioButtons out of the Designer UI then create and position the radio buttons after setupUI()
                • Build the whole UI in code.
                1 Reply Last reply
                2

                • Login

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