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. [solved] automatically anchor elements when phone rotates
Qt 6.11 is out! See what's new in the release blog

[solved] automatically anchor elements when phone rotates

Scheduled Pinned Locked Moved Mobile and Embedded
7 Posts 3 Posters 3.1k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hello,

    I created a new Qt Widget Project -> Mobile Qt Application and want to automatically apply this code to anchor the pushbutton always when the phone rotates (I have ScreenOrientationAuto, btw.)

    @ui->pushButton->setGeometry(0,0,ui->centralWidget->width(),ui->centralWidget->height() / 2);@

    Thank you

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      If you are using QWidgets, then this is the wrong forum:-)

      QWidgets can to do the anchoring that QML does. You can archive this effect using a layout though.

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Yes, I am using QWidgets in this project now.

        Can you tell me a forum to ask about Layout for anchoring ?
        Edit: I now found the layout thing in the designer, but I still need a forum to ask questions about things conserning QWidget.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mlong
          wrote on last edited by
          #4

          Moved to Mobile & Embedded (although it could have been General/Desktop.)

          Software Engineer
          My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            Can I also work with ratios, like if I have two parts, that the first part takes 80% and the rest 20% ? How to set that ?

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mlong
              wrote on last edited by
              #6

              "Layouts":/doc/qt-4.8/layout.html will give you the functionality you're looking for. (Look at "Stretch Factors" for percentage widths.)

              Software Engineer
              My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

                This looks appropiate. Thanks for the help, and now I also know where to find the forum.

                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