QT Question - What are all these extra spaces for ? (pic provided)
stack overflow wont let me post images so heres the link:
http://4m0.org/images/qt.png
This is 开发者_如何学编程my application. For this question, ignore the top part with the buttons.
I have a QScrollArea
Filled with many QGroupBoxes
Filled with a horizontal box layout of QLabel (on the left) and QGroupBox (on the right)
The right side is a vertical box layout of QPushButtons
Every single element, the scrollarea, both boxes, the labels, and the buttons all have their style sheets modified so padding is 0px and margin is 0px.
Why do i have all this extra space?
The scroll area has space on all sides until its inner elements (the blue boxes) start. Then those boxes have space until its inner elements (the white boxes) start.
Can someone tell me what is going on?
Why do i have all this extra space?
If I get you right, you need edit your layout code with this, to exclude unneeded spaces:
QVBoxLayout *buttonsLayout = new QVBoxLayout;
buttonsLayout->setContentsMargins(0, 0, 0, 0); // remove spaces
buttonsLayout->setSpacing(0);
buttonsLayout->addWidget(daysButton);
...
Catch layout of your QScrollArea
QLayout *layout = myScrollArea->layout();
layout->setSpacing(0);
layout->setContentsMargins ( 0, 0, 0, 0 );
精彩评论