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. are there only five kinds of layouts in Qt?
QtWS25 Last Chance

are there only five kinds of layouts in Qt?

Scheduled Pinned Locked Moved Solved General and Desktop
qt 6qlayoutlayout
4 Posts 4 Posters 289 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.
  • M Offline
    M Offline
    markleo
    wrote on 23 Dec 2024, 15:19 last edited by
    #1

    The Qt layouts we often see are as follows: There are five kinds (all inherited from QLayout).

    QHBoxLayout
    QVBoxLayout
    QGridLayout
    QFormLayout
    QStackedLayout
    

    However, I have seen other names related to Layout in the official documentation.
    For example:

    QPageLayout
    QTextLayout
    

    and so on.

    Are these used for layout? Or are there only five kinds of layouts in Qt?

    C K P 3 Replies Last reply 23 Dec 2024, 15:44
    0
    • M markleo
      23 Dec 2024, 15:19

      The Qt layouts we often see are as follows: There are five kinds (all inherited from QLayout).

      QHBoxLayout
      QVBoxLayout
      QGridLayout
      QFormLayout
      QStackedLayout
      

      However, I have seen other names related to Layout in the official documentation.
      For example:

      QPageLayout
      QTextLayout
      

      and so on.

      Are these used for layout? Or are there only five kinds of layouts in Qt?

      P Offline
      P Offline
      Pl45m4
      wrote on 24 Dec 2024, 03:17 last edited by
      #4

      @markleo said in are there only five kinds of layouts in Qt?:

      Or are there only five kinds of layouts in Qt?

      Yes and no.
      In most cases these are the base layouts used. However there are also custom layouts with "special" behavior, like
      FlowLayout from the Flow Layout Example.
      That being said, you can combine the basic layout or build your own layout, if you really need something different (what you cannot reproduce using the five above).


      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
      • M markleo
        23 Dec 2024, 15:19

        The Qt layouts we often see are as follows: There are five kinds (all inherited from QLayout).

        QHBoxLayout
        QVBoxLayout
        QGridLayout
        QFormLayout
        QStackedLayout
        

        However, I have seen other names related to Layout in the official documentation.
        For example:

        QPageLayout
        QTextLayout
        

        and so on.

        Are these used for layout? Or are there only five kinds of layouts in Qt?

        C Online
        C Online
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on 23 Dec 2024, 15:44 last edited by
        #2

        @markleo said in are there only five kinds of layouts in Qt?:

        Are these used for layout?

        You already mentioned the documentation so:

        https://doc.qt.io/qt-6/qpagelayout.html#details
        https://doc.qt.io/qt-6/qtextlayout.html#details

        Or are there only five kinds of layouts in Qt?

        What are you missing?

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        0
        • M markleo
          23 Dec 2024, 15:19

          The Qt layouts we often see are as follows: There are five kinds (all inherited from QLayout).

          QHBoxLayout
          QVBoxLayout
          QGridLayout
          QFormLayout
          QStackedLayout
          

          However, I have seen other names related to Layout in the official documentation.
          For example:

          QPageLayout
          QTextLayout
          

          and so on.

          Are these used for layout? Or are there only five kinds of layouts in Qt?

          K Offline
          K Offline
          KH-219Design
          wrote on 23 Dec 2024, 21:43 last edited by
          #3

          @markleo said in are there only five kinds of layouts in Qt?:

          Are these used for layout?

          To see whether any class you are examining can be used for GUI layout (such as placing buttons and other things on a window), you should check whether it:

          • Inherits: QLayout

          QWidget::setLayout only accepts pointers to objects that are a (sub-) type of QLayout. (Per docs for QWidget.)

          QPageLayout is not a subtype of QLayout. You can investigate the others as needed. If it isn't a subtype of QLayout, you will not be able to compile code that attempts to pass it to setLayout.

          We could make subjective arguments and counter-arguments about whether the similarity in naming is "confusing" or not. (I offer no opinion on that.)

          However, the compiler will ultimately tell you exactly what qualifies as a valid QLayout pointer. So when it comes time to compile the code, any such confusion should very quickly be illuminated.

          www.219design.com
          Software | Electrical | Mechanical | Product Design

          1 Reply Last reply
          0
          • M markleo
            23 Dec 2024, 15:19

            The Qt layouts we often see are as follows: There are five kinds (all inherited from QLayout).

            QHBoxLayout
            QVBoxLayout
            QGridLayout
            QFormLayout
            QStackedLayout
            

            However, I have seen other names related to Layout in the official documentation.
            For example:

            QPageLayout
            QTextLayout
            

            and so on.

            Are these used for layout? Or are there only five kinds of layouts in Qt?

            P Offline
            P Offline
            Pl45m4
            wrote on 24 Dec 2024, 03:17 last edited by
            #4

            @markleo said in are there only five kinds of layouts in Qt?:

            Or are there only five kinds of layouts in Qt?

            Yes and no.
            In most cases these are the base layouts used. However there are also custom layouts with "special" behavior, like
            FlowLayout from the Flow Layout Example.
            That being said, you can combine the basic layout or build your own layout, if you really need something different (what you cannot reproduce using the five above).


            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
            • M markleo has marked this topic as solved on 2 Jan 2025, 06:53

            3/4

            23 Dec 2024, 21:43

            • Login

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