Results 1 to 3 of 3

Thread: Margins around QWidget - Unwanted

  1. #1
    Join Date
    Jan 2013
    Location
    England
    Posts
    13
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    7

    Unhappy Margins around QWidget - Unwanted

    Hello,

    I seem to be getting a white margin or border that I have never got before, but it is disrupting my background image and basically very unsightly!

    Capture.jpg


    Here is my code:
    Qt Code:
    1. MainMenu::MainMenu(QWidget *parent)
    2. : QWidget(parent)
    3.  
    4. {
    5.  
    6.  
    7. QSize Appsize(1200,650);
    8. QSize buttonsize(200,68);
    9. QSize helpbuttonsize(50,50);
    10.  
    11.  
    12.  
    13.  
    14. QPushButton *MainMenuButton = new QPushButton(this);
    15. QPushButton *QuadraticButton = new QPushButton(this);
    16. QPushButton *PythagorasButton = new QPushButton(this);
    17. QPushButton *TrigonometryButton = new QPushButton(this);
    18. QPushButton *SimButton = new QPushButton(this);
    19. QPushButton *TwoDButton = new QPushButton(this);
    20. QPushButton *ThreeDButton = new QPushButton(this);
    21. QSpacerItem *Spacer0001 = new QSpacerItem(100, 450, QSizePolicy::Ignored, QSizePolicy::Ignored);
    22. MainMenuButton -> setFixedSize(buttonsize);
    23. QuadraticButton -> setFixedSize(buttonsize);
    24. PythagorasButton -> setFixedSize(buttonsize);
    25. TrigonometryButton -> setFixedSize(buttonsize);
    26. SimButton -> setFixedSize(buttonsize);
    27. TwoDButton -> setFixedSize(buttonsize);
    28. ThreeDButton -> setFixedSize(buttonsize);
    29.  
    30.  
    31.  
    32.  
    33.  
    34.  
    35.  
    36. QWidget *MainMenuWidget = new QWidget(this);
    37. QGridLayout *MainMenuLayout = new QGridLayout(this);
    38.  
    39.  
    40. MainMenuLayout -> addItem(Spacer0001,1,1,1,1,Qt::AlignLeft);
    41. MainMenuLayout -> addWidget(MainMenuButton,3,1,1,1,Qt::AlignLeft);
    42. MainMenuLayout -> addWidget(QuadraticButton,4,1,1,1,Qt::AlignLeft);
    43. MainMenuLayout -> addWidget(PythagorasButton,5,1,1,1,Qt::AlignLeft);
    44. MainMenuLayout -> addWidget(TrigonometryButton,6,1,1,1,Qt::AlignLeft);
    45. MainMenuLayout -> addWidget(SimButton,7,1,1,1,Qt::AlignLeft);
    46. MainMenuLayout -> addWidget(TwoDButton,8,1,1,1,Qt::AlignLeft);
    47. MainMenuLayout -> addWidget(ThreeDButton,9,1,1,1,Qt::AlignLeft);
    48. MainMenuWidget -> setLayout(MainMenuLayout);
    49.  
    50.  
    51. QWidget *QuadraticWidget = new QWidget(this);
    52. QGridLayout *QuadraticLayout = new QGridLayout(this);
    53.  
    54.  
    55.  
    56. QuadraticWidget -> setLayout(QuadraticLayout);
    57.  
    58.  
    59. QWidget *PythagorasWidget = new QWidget(this);
    60. QGridLayout *PythagorasLayout = new QGridLayout(this);
    61.  
    62.  
    63.  
    64. PythagorasWidget -> setLayout(PythagorasLayout);
    65.  
    66.  
    67. QWidget *TrigonometryWidget = new QWidget(this);
    68. QGridLayout *TrigonometryLayout = new QGridLayout(this);
    69.  
    70.  
    71.  
    72. TrigonometryWidget -> setLayout(TrigonometryLayout);
    73.  
    74.  
    75. QWidget *SimWidget = new QWidget(this);
    76. QGridLayout *SimLayout = new QGridLayout(this);
    77.  
    78.  
    79.  
    80. SimWidget -> setLayout(SimLayout);
    81.  
    82. QWidget *TwoDWidget = new QWidget(this);
    83. QGridLayout *TwoDLayout = new QGridLayout(this);
    84.  
    85.  
    86.  
    87. TwoDWidget -> setLayout(TwoDLayout);
    88.  
    89.  
    90. QWidget *ThreeDWidget = new QWidget(this);
    91. QGridLayout *ThreeDLayout = new QGridLayout(this);
    92.  
    93.  
    94.  
    95. ThreeDWidget -> setLayout(ThreeDLayout);
    96.  
    97.  
    98.  
    99. MainMenuWidget -> setStyleSheet("background-image: url(Graphics/Template.png)");
    100. QuadraticWidget -> setStyleSheet("background-image: url(Graphics/Template.png)");
    101. PythagorasWidget -> setStyleSheet("background-image: url(Graphics/Template.png)");
    102. TrigonometryWidget -> setStyleSheet("background-image: url(Graphics/Template.png)");
    103. SimWidget -> setStyleSheet("background-image: url(Graphics/Template.png)");
    104. TwoDWidget -> setStyleSheet("background-image: url(Graphics/Template.png)");
    105. ThreeDWidget -> setStyleSheet("background-image: url(Graphics/Template.png)");
    106.  
    107. this -> setFixedSize(Appsize);
    108.  
    109.  
    110.  
    111.  
    112.  
    113. QStackedWidget *Stack = new QStackedWidget(this);
    114. Stack -> addWidget(MainMenuWidget);
    115. Stack -> addWidget(QuadraticWidget);
    116. Stack -> addWidget(PythagorasWidget);
    117. Stack -> addWidget(TrigonometryWidget);
    118. Stack -> addWidget(SimWidget);
    119. Stack -> addWidget(TwoDWidget);
    120. Stack -> addWidget(ThreeDWidget);
    121.  
    122. QVBoxLayout *layout = new QVBoxLayout(this);
    123. layout->addWidget(Stack,Qt::AlignCenter);
    124. setLayout(layout);
    125. }
    To copy to clipboard, switch view to plain text mode 

    Unfortunately I have had to shorted the code quite significantly as it was around 30,000 characters but I have only removed other pages buttons and layouts which are the same as the mainmenu
    Any help on this topic would be greatly appreciated, or just something to go and read so that I can fix it - I think it could be because of the stackedwidget as I haven't experienced this before.

    Thanks
    Last edited by Jake123; 26th January 2013 at 11:17.

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

    Default Re: Margins around QWidget - Unwanted

    Set margins to 0.
    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.


  3. The following user says thank you to wysota for this useful post:

    Jake123 (26th January 2013)

  4. #3
    Join Date
    Jan 2013
    Location
    England
    Posts
    13
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    7

    Default Re: Margins around QWidget - Unwanted

    Quote Originally Posted by wysota View Post
    Set margins to 0.

    Thanks! worked perfect (yet so obvious!)

Similar Threads

  1. Unwanted white border
    By Jake123 in forum Newbie
    Replies: 1
    Last Post: 26th January 2013, 12:16
  2. QTreeView and unwanted scrollbar
    By theprobe in forum Qt Programming
    Replies: 2
    Last Post: 12th January 2011, 08:19
  3. QGraphicsView unwanted margin
    By hheld in forum Qt Programming
    Replies: 4
    Last Post: 3rd January 2011, 17:16
  4. Unwanted padding on QWidget
    By etru1927 in forum Qt Programming
    Replies: 4
    Last Post: 7th August 2008, 07:42
  5. QMdiArea unwanted actvation
    By fullmetalcoder in forum Qt Programming
    Replies: 7
    Last Post: 12th November 2007, 07:09

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.