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. How to create a "corner" widget with Qsplitter or so
Forum Updated to NodeBB v4.3 + New Features

How to create a "corner" widget with Qsplitter or so

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.3k 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.
  • R Offline
    R Offline
    rickyviking
    wrote on last edited by
    #1

    Hi all,

    I'd like to obtain a layout in which I have 2 widgets of which one is placed in a corner, see the image below:

    !http://i.imgur.com/H27WY.png(corner layout)!

    Ideally, the 2 red lines would be QSplitter, so that the corner widget would be resizable.
    Is it possible to obtain such a layout??
    thank you.
    Ricky

    1 Reply Last reply
    0
    • napajejenunedk0N Offline
      napajejenunedk0N Offline
      napajejenunedk0
      wrote on last edited by
      #2

      You mean two overlapping widgets? Then you should check out "QStackedLayout":http://qt-project.org/doc/qt-4.8/qstackedlayout.html and set the QStackedLayout::StackingMode to QStackedLayout::StackAll.

      @
      QStackedLayout* mainLayout = new QStackedLayout;
      mainLayout->setStackingMode( QStackedLayout::StackAll );

      QWidget* greaterWidget = new QWidget;
      mainLayout->addWidget( greaterWidget );

      QWidget* cornerWidget = new QWidget;
      QWidget* alignmentWidget = new QWidget;
      QGridLayout* alignmentLayout = new QGridLayout( alignmentWidget );
      alignmentLayout->addWidget( cornerWidget, 0, 0, Qt::AlignRight | Qt::AlignBottom );

      mainLayout->addWidget( alignmentWidget );
      mainLayout->setCurrentWidget( alignmentWidget );
      @

      The alignmentWidget is needed to position the corner widget at the bottom-right, since QStackedLayout's insertWidget function doesn't allow for specifying the alignment of the widget being added.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rickyviking
        wrote on last edited by
        #3

        Hi Napaje,

        thanks for your hint.
        I'm probably missing something to have your code working on my side.
        I had to add a Box Layout above the Stacked one to see something appear.
        But it works only when I use StackOne, when I use StackAll and add the 2 widgets (greater and corner) I get nothing.
        I've also tried to specify manually the geometry of the cornerWidget but nothing changes.

        Anyway I got the idea, but in the configuration you suggest would the red borders be movable, so to allow the cornerWidget to be resized?

        Thank you!
        Ricky

        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