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. Positioning widgets
Forum Updated to NodeBB v4.3 + New Features

Positioning widgets

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 4 Posters 433 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.
  • D Offline
    D Offline
    DevM
    wrote on last edited by
    #1

    I was wondering what's the "most accepted way" about positioning widgets and other elements on QT.

    Should I do it by code or by forms?

    This came up because I'm trying to make a Qpixmap image have its position relative to a point so if I resize the window it doesn't stay in the same place, I have searched anchoring but the examples I found uses a Qgraphicsscene which I'm not sure at all if it is what I need.

    Thanks!

    1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by
      #2

      learn the layouts, the size hints, and the size policies.

      1 Reply Last reply
      2
      • D Offline
        D Offline
        DevM
        wrote on last edited by DevM
        #3

        Im assuming you mean these
        Screenshot_5.png

        My main doubt is what is the preferred way to do it, if by code or if using the QCreator Form tab.

        These layouts are useful if I want to do it by code though so thanks !

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

          Hi,

          The prefered way is whatever fits best with you. Some like designer because they can directly see the widgets look and other prefer to do everything by code because they are used to that and can visualize the result without designer. It's more a question of taste.

          Personally I never use Designer except when there's a need to debug it or do a test for something related to it. However, I think that it's a nice tool that allow people to create their interface visually easily.

          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
          3
          • D Offline
            D Offline
            DevM
            wrote on last edited by
            #5

            Got it! Thanks :)

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

              Hi
              And just to have both ways.
              I mostly do all in Designer and love the promotion feature allowing me to design with a custom widget.
              I use the dynamic property system to allow Design time customization for my custom widgets
              and the only code i write is for the dynamic parts. (loading data ) and for the parts
              that Designer do not support.

              Also, for a team, using UI files makes it easier for the non-UX developers to add a button and such
              without having to know exactly how it works as it's easy to drag a widget from left to someplace on the form/in the layout. Finding the same spot in many lines of code is not that easy.

              Also, designing complex layout using a Designer is good for leaning as you see the result at once.
              From code, you have to run to see what you got.

              That said, writing layouts in code, gives a firm understanding of how they work.

              For your case. Qt does not have anchoring as such with Widgets
              so unless one of the layouts suits the case, then manually setting the pixmap pos in resizeEvent
              is also an option.

              1 Reply Last reply
              4

              • Login

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