Results 1 to 4 of 4

Thread: zero'ing margin in a qhboxlayout

  1. #1
    Join Date
    Feb 2006
    Posts
    29
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Windows

    Default zero'ing margin in a qhboxlayout

    i've got a simple widget that contains 2 children: a stackedwidget and a button. i applied a horizontal layout to it and was able to make all the margins zero.

    in the stackedwidget, there is a single lineedit on one page and a date/time edit on the other page, both with horizontal layouts. with these layouts, however, i can't seem to zero out the margins. this causes part of the lineedit or date edit to be cut off when the widget is a certain height, which it's supposed to be. i attached the ui file for reference. i just want the entire widget to be the exact height of the lineedit.

    how do i zero out these margins?

    thanks! -- lou
    Attached Files Attached Files

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: zero'ing margin in a qhboxlayout

    Make sure that
    1. stacked layout of stacked widget has zero margins (AFAIK not possible via designer)
    2. page layouts have zero margins (in designer select pages from object inspector and set /Layout/Margin property)

    The following code would do this:
    Qt Code:
    1. stackedWidget->layout()->setMargin(0); // 1.
    2. for (int i = 0; i < ui.stackedWidget->count(); ++i)
    3. stackedWidget->widget(i)->layout()->setMargin(0); // 2. (assumes that pages have layout installed)
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. #3
    Join Date
    Feb 2006
    Posts
    29
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: zero'ing margin in a qhboxlayout

    Quote Originally Posted by jpn View Post
    Make sure that
    1. stacked layout of stacked widget has zero margins (AFAIK not possible via designer)
    2. page layouts have zero margins (in designer select pages from object inspector and set /Layout/Margin property)

    The following code would do this:
    Qt Code:
    1. stackedWidget->layout()->setMargin(0); // 1.
    2. for (int i = 0; i < ui.stackedWidget->count(); ++i)
    3. stackedWidget->widget(i)->layout()->setMargin(0); // 2. (assumes that pages have layout installed)
    To copy to clipboard, switch view to plain text mode 
    does setmargin exist in qt4? i looked in the documentation and only found it in q3 residual classes. i couldn't find in the docs how to set the margin. any ideas?

    thanks! -- lou

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: zero'ing margin in a qhboxlayout

    QLayout::setMargin() was made obsolete in Qt 4.3. Documentation proposes using QLayout::setContentsMargins() instead.
    J-P Nurmi

  5. The following user says thank you to jpn for this useful post:

    illuzioner (3rd July 2007)

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.