문제

This is my UI enter image description here

I hope I could move red border to left or right in the picture by mouse when the program run.

How should I do?

도움이 되었습니까?

해결책

Add all those widgets to the form in the UI designer. Select text edit widget and list widget. Select "Lay Out Horizontally in Splitter" from the top toolbar. Then select the form itself and select "Lay Out Vertically" from the top toolbar. That's it, except the list widget is not dockable.

Edit:

If you want to keep the list widget at constant size (so that it is resized only by the user), tell the QSplitter the stretch factors of the widgets, for example like this:

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent), ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    // index 0 is the text edit, stretch factor is 1 (= all stretching goes here)
    ui->splitter->setStretchFactor(0, 1); 

    // index 1 is the list widget, stretch factor is 0
    ui->splitter->setStretchFactor(1, 0);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top