[英]Qt QGridLayout setRowStretch not working
我是Qt的新手。 我正在尝试使用以下布局创建一个窗口,
--------------------------
| Button1 | Button2 |
| ------------------------ |
| -------图片-------- |
-------------------------
我可以使用QGridlayout创建此布局。 请参阅以下代码,
QPushButton *button = new QPushButton(this);
QPushButton *nextButton = new QPushButton(this);
button->setText("Select new Image");
nextButton->setText("Next Image >>");
button->setMinimumSize(100,50);
nextButton->setMaximumSize(500,50);
button->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
nextButton->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
this->centralWidget = new QWidget(this);
this->centralWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
this->centralWidget->setGeometry(0,0,800,800);
QPalette Pal(palette());
Pal.setColor(QPalette::Background, Qt::black);
this->centralWidget->setAutoFillBackground(true);
this->centralWidget->setPalette(Pal);
this->layout = new QGridLayout (centralWidget);
this->layout->addWidget(button,0,0,1,1);
this->layout->addWidget(nextButton,0,1,1,1);
this->layout->addWidget(this->imageLabel,1,0,1,1);
this->layout->setRowStretch(0,1);
this->layout->setRowStretch(1,10);
但是我要的是图像应该占据更多的空间,但是图像只显示在窗口的下半部分。 请查看图像您可以看到按钮和图像之间的空间。 我要删除空间。
我尝试使用setRowStretch,但这无济于事。
PS:我在Qt插件中使用eclipse。 另外我做出的一些选择也许很差。 我是Qt的新手。 非常感谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.