Results 1 to 4 of 4

Thread: Problem with QScrollArea layout and alignment

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2011
    Posts
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with QScrollArea layout and alignment

    I'm using qt designer

    Qt Code:
    1. tabWidget = new QTabWidget(splitter);
    2. tabWidget->setObjectName(QString::fromUtf8("tabWidget"));
    3. QSizePolicy sizePolicy2(QSizePolicy::Preferred, QSizePolicy::Expanding);
    4. sizePolicy2.setHorizontalStretch(0);
    5. sizePolicy2.setVerticalStretch(0);
    6. sizePolicy2.setHeightForWidth(tabWidget->sizePolicy().hasHeightForWidth());
    7. tabWidget->setSizePolicy(sizePolicy2);
    8. tabWidget->setMaximumSize(QSize(300, 16777215));
    9. General = new QWidget();
    10. General->setObjectName(QString::fromUtf8("General"));
    11. scrollArea = new QScrollArea(General);
    12. scrollArea->setObjectName(QString::fromUtf8("scrollArea"));
    13. scrollArea->setGeometry(QRect(9, 9, 276, 635));
    14. QSizePolicy sizePolicy3(QSizePolicy::Fixed, QSizePolicy::Maximum);
    15. sizePolicy3.setHorizontalStretch(0);
    16. sizePolicy3.setVerticalStretch(0);
    17. sizePolicy3.setHeightForWidth(scrollArea->sizePolicy().hasHeightForWidth());
    18. scrollArea->setSizePolicy(sizePolicy3);
    19. scrollArea->setMinimumSize(QSize(0, 0));
    20. scrollArea->setWidgetResizable(true);
    21. scrollArea->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop);
    22. scrollAreaWidgetContents = new QWidget();
    23. scrollAreaWidgetContents->setObjectName(QString::fromUtf8("scrollAreaWidgetContents"));
    24. scrollAreaWidgetContents->setGeometry(QRect(0, 0, 257, 963));
    25. verticalLayout_4 = new QVBoxLayout(scrollAreaWidgetContents);
    26. verticalLayout_4->setSpacing(6);
    27. verticalLayout_4->setContentsMargins(6, 6, 6, 6);
    28. verticalLayout_4->setObjectName(QString::fromUtf8("verticalLayout_4"));
    29. Namebox = new QGroupBox(scrollAreaWidgetContents);
    30. Namebox->setObjectName(QString::fromUtf8("Namebox"));
    31. QSizePolicy sizePolicy4(QSizePolicy::Preferred, QSizePolicy::Maximum);
    32. sizePolicy4.setHorizontalStretch(0);
    33. sizePolicy4.setVerticalStretch(0);
    34. sizePolicy4.setHeightForWidth(Namebox->sizePolicy().hasHeightForWidth());
    35. Namebox->setSizePolicy(sizePolicy4);
    36. Namebox->setMaximumSize(QSize(16777215, 53));
    37. Namebox->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop);
    38. horizontalLayout_6 = new QHBoxLayout(Namebox);
    39. horizontalLayout_6->setSpacing(6);
    40. horizontalLayout_6->setContentsMargins(6, 6, 6, 6);
    41. horizontalLayout_6->setObjectName(QString::fromUtf8("horizontalLayout_6"));
    To copy to clipboard, switch view to plain text mode 


    if you prefer you can download the ui file here

    thanks!

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,540
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with QScrollArea layout and alignment

    Do not use restrictions on the size of the frames. See how it looks awful on another computer.
    bad_layout.jpg. Second at the end (as last widget on scroll area) put vertical spacer.

Similar Threads

  1. Replies: 6
    Last Post: 13th August 2011, 18:31
  2. Replies: 6
    Last Post: 13th February 2011, 23:06
  3. Replies: 10
    Last Post: 9th June 2010, 14:12
  4. QScrollArea: clearing the layout of the inner widget
    By mattc in forum Qt Programming
    Replies: 1
    Last Post: 3rd August 2009, 08:09
  5. Qt Layout alignment
    By bunjee in forum Qt Programming
    Replies: 1
    Last Post: 18th December 2007, 19:15

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
  •  
Qt is a trademark of The Qt Company.