【Qt開發】布局控件之間的間距設置


void QLayout::setContentsMargins ( int left, int top, int right, int bottom )

Sets the lefttopright, and bottom margins to use around the layout.

By default, QLayout uses the values provided by the style. On most platforms, the margin is 11 pixels in all directions.

This function was introduced in Qt 4.3.

 

這個說默認有11像素的間隙。

測試不行。

//hlayout->setContentsMargins(0,0,0,0);

//hlayout->setContentsMargins(QMargins(0,0,0,0));

 

主要通過setMargin(0) 設置Layout 的外部邊界為0

 

    hlayout->addWidget(start);
    hlayout->addWidget(settle);
    hlayout->addWidget(treatement);
    hlayout->addWidget(final);
    //hlayout->setStretchFactor(hlayout,0);
    hlayout->setMargin(0);
    //hlayout->setContentsMargins(0,0,0,0);
    //hlayout->setContentsMargins(QMargins(0,0,0,0));
    hlayout->setSpacing(0);
    //這個設置成功


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM