Results 1 to 2 of 2

Thread: QStackedLayout and setContentsMargins()

  1. #1
    Join Date
    May 2009
    Posts
    52
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default QStackedLayout and setContentsMargins()

    setContentsMargins() seems to not have any effect on QStackedLayout.

    This code results in no margin:

    Qt Code:
    1. mainLayout = new QStackedLayout(this);
    2. mainLayout->setContentsMargins(20, 20, 20, 20);
    3. mainLayout->addWidget(image);
    4. mainLayout->addWidget(text);
    5. mainLayout->setCurrentIndex(0);
    To copy to clipboard, switch view to plain text mode 

    while this has the correct 20 pixels margin

    Qt Code:
    1. QVBoxLayout* mainLayout = new QVBoxLayout(this);
    2. mainLayout->setContentsMargins(20, 20, 20, 20);
    3. mainLayout->addWidget(image);
    To copy to clipboard, switch view to plain text mode 

    Any idea how I can have the margin on QStackedLayout?

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QStackedLayout and setContentsMargins()

    Put it inside a QVBoxLayout with a contentsMargin. Or use QStackedWidget.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 1
    Last Post: 14th January 2011, 02:52
  2. QMainWindow and setContentsMargins
    By themolecule in forum Qt Programming
    Replies: 0
    Last Post: 7th February 2010, 19:03
  3. Question about setContentsMargins for QSplitter
    By TorAn in forum Qt Programming
    Replies: 0
    Last Post: 23rd December 2009, 15:28
  4. QToolbar setContentsMargins
    By rshabsin in forum Qt Programming
    Replies: 2
    Last Post: 18th September 2007, 22:12
  5. setContentsMargins in QAbstractItemView
    By Promethee in forum Qt Programming
    Replies: 2
    Last Post: 4th February 2006, 14:40

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.