Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. change location of QWidgets using setGeometry

change location of QWidgets using setGeometry

Scheduled Pinned Locked Moved Mobile and Embedded
6 Posts 2 Posters 1.7k 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.
  • Awadhesh MauryaA Offline
    Awadhesh MauryaA Offline
    Awadhesh Maurya
    wrote on last edited by
    #1

    Hi,
    I want set locations of QWidgets like pushbuttons, Labels etc in a widget, but by using setGeometry, sometimes only size is changing and never change the locations.

    I am using 800x480 screen. I want to set pushbutton on right-bottom corner, but it always locate in left-middle regardless of coordinate in setGeometry.

    QPushButton *backBtn = new QPushButton;
    backBtn->setStyleSheet("QPushButton {background-color : lightblue; color : black;}");
    backBtn->setGeometry(QRect(600, 400, 120, 40));
    backBtn->setMinimumSize(QSize(0,0));
        backBtn->setMaximumSize(QSize(200,200));
    

    In my application I want work setGeometry must work properly.

    Please help me regarding it.

    1 Reply Last reply
    0
    • Awadhesh MauryaA Offline
      Awadhesh MauryaA Offline
      Awadhesh Maurya
      wrote on last edited by Awadhesh Maurya
      #2

      After initialization in constructor, I do setGeometry then only it will stay on their absolute coordinates.
      But there are other issues like if I will do setStyleSheet, setText after initialization for widgets, it will again disturb the absolute locations.

      Please let me know it.

      Thanks.

      1 Reply Last reply
      0
      • Awadhesh MauryaA Offline
        Awadhesh MauryaA Offline
        Awadhesh Maurya
        wrote on last edited by
        #3

        If I do setStyleSheet or setText for any QLabel, all widgets positions are disturb.

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

          Hi,

          Out of curiosity, why are you not using a layout manager ?

          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
          • Awadhesh MauryaA Offline
            Awadhesh MauryaA Offline
            Awadhesh Maurya
            wrote on last edited by
            #5

            Hi,
            Currently I am using QVBoxLayout and I have checked for other layout also. But all are rearranged after any setText or setStyleSheet.
            My requirement is that I have a background image, some points in that image I want to use as push buttons, so it should not be horizontal, vertical, grid etc its only random locations.

            I am using it as a page, so I used QStackedWidget to handle pages.

            Please tell me which layout is suitable for it or any other way to solve it.

            Thanks.

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

              if you have something where your controls are randomly placed then you can't use a layout manager. However you should maybe take a look at the Graphics View frame work and maybe QML

              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

              • Login

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