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. SetAlignment for QStackedLayout
Forum Updated to NodeBB v4.3 + New Features

SetAlignment for QStackedLayout

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 4.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.
  • J Offline
    J Offline
    jesuisbenjamin
    wrote on last edited by
    #1

    Hello,

    I use a QStackedWidget, and append a QLabel to it, I want this QLabel to be centered vertically as well as horizontally. I tried using my_stack.layout().setAlignment(QtCore.Qt.AlignCenter) as well as my_stack.layout().setAlignment(my_label, QtCore.Qt.AlignCenter) but none would work.

    Why does the alignment does not take effect as it does with QBoxLayout?

    Should I use the QStackedLayout alone instead? Perhaps the layout alignment must be set before the layout itself is set?

    Thanks for the help.
    B.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jesuisbenjamin
      wrote on last edited by
      #2

      PS: I just tried using the QStackedLayout directly and setting the Alignment before setting the layout did not help.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jesuisbenjamin
        wrote on last edited by
        #3

        I can't figure out what the matter is with QStackedLayout, but I worked around it by placing a QFrame in that layout, with a QHBoxLayout and a centered widget.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          Using QStackedWidget would have worked just fine, you only needed to set a layout on each of the pages in it. That would have centered your label just fine.

          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