私はQtが初めてです。次のレイアウトでウィンドウを作成しようとしていますが、
--------------------------
| ボタン 1 | ボタン 2|
|------------------------|
|-------- 画像--------|
-------------------------
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が初めてです。どうもありがとう