I have created a Qt application with the following structure:
*
.
└── QMdiArea
* * * * └── HeaderDataBrowser
* * * * * * * * * * ├── QScrollArea1
* * * * * * * * * * └── QScrollArea2
* * * * * * * * * * * * * * ├── QwtPlot1
* * * * * * * * * * * * * * └── QwtPlot2
.
└── QMdiArea
* * └── QTabWidget
* * * * └── HeaderDataBrowser
* * * * * * └── QVBoxLayout
* * * * * * * * └── QSplitter
* * * * * * * * * * ├── QScrollArea1
* * * * * * * * * * │ * └── QVBoxLayout
* * * * * * * * * * │ * * * └── QTreeWidget
* * * * * * * * * * └── QScrollArea2
* * * * * * * * * * * * └── QVBoxLayout
* * * * * * * * * * * * * * ├── QwtPlot1
* * * * * * * * * * * * * * └── QwtPlot2
To copy to clipboard, switch view to plain text mode
I'm having multiple issues.
1) It appears the parent widgets of the QwtPlot widgets are ignoring the minimum size constraints. The plots just start overlapping when things get small.
2) Even though the QwtPlot widgets are inside a QScrollArea, no scrollbars ever appear, even when resizing ridiculously small. Why?
3) Issue 1) applies to a lot of the other parent widgets. They just ignore the minimum size constraints of their child widgets.
*
This video demonstrates the issues I'm having.
1) The first run shows that the app can be scaled right down to a size that shouldn't be possible.
2) I then set the minimum size of both QwtPlot widgets to 200, 200. Now the plots don't resize smaller than 200, 200, but they begin overlapping each other. What I really want is to restrict the app's minimum size so that doesn't happen.
3) I then set the minimum size of the splitter widget to 300, 300 and show that the parent widgets of the application simply do not care. The scroll area gets clipped as the application is scaled down.
*
*
The following code replicates this behaviour (note: I'm running Qt5. Qt4 seems to have different behaviour for some reason):
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QVBoxLayout>
#include <QMdiArea>
#include <QSplitter>
#include <QScrollArea>
#include <QTreeWidget>
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
QMdiArea* mdi = new QMdiArea;
ui->centralWidget->layout()->addWidget(mdi);
mdi->addSubWindow(tabWidget);
tabWidget->showMaximized();
tabWidget->addTab(headerDataBrowser, "Header");
// Header data tree goes on the left side, TxSeq plots on the right
browserLayout->addWidget(splitter);
headerDataBrowser->setLayout(browserLayout);
// Create scroll area and put a tree view inside it. Then add the scroll
// area to the left side of the splitter
scroll->setWidgetResizable(true);
splitter->addWidget(scroll);
scroll->setLayout(scrollLayout);
scrollLayout->addWidget(treeWidget);
// Create layout on right side of splitter. This is where the plots are
// inserted. Also add it to a scroll area, but disable horizontal
// scrolling.
//plotArea->setWidgetResizable(true);
//plotArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOf f);
splitter->addWidget(plotArea);
plotArea->setLayout(plotLayout);
// add some crap
for(int i = 0; i != 20; ++i)
}
MainWindow::~MainWindow()
{
delete ui;
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QVBoxLayout>
#include <QMdiArea>
#include <QSplitter>
#include <QScrollArea>
#include <QTreeWidget>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->centralWidget->setLayout(new QVBoxLayout);
QMdiArea* mdi = new QMdiArea;
ui->centralWidget->layout()->addWidget(mdi);
QTabWidget* tabWidget = new QTabWidget;
mdi->addSubWindow(tabWidget);
tabWidget->showMaximized();
QWidget* headerDataBrowser = new QWidget;
tabWidget->addTab(headerDataBrowser, "Header");
// Header data tree goes on the left side, TxSeq plots on the right
QVBoxLayout* browserLayout = new QVBoxLayout;
QSplitter* splitter = new QSplitter(headerDataBrowser);
browserLayout->addWidget(splitter);
headerDataBrowser->setLayout(browserLayout);
// Create scroll area and put a tree view inside it. Then add the scroll
// area to the left side of the splitter
QScrollArea* scroll = new QScrollArea;
scroll->setWidgetResizable(true);
splitter->addWidget(scroll);
QVBoxLayout* scrollLayout = new QVBoxLayout;
scroll->setLayout(scrollLayout);
QTreeWidget* treeWidget = new QTreeWidget;
scrollLayout->addWidget(treeWidget);
// Create layout on right side of splitter. This is where the plots are
// inserted. Also add it to a scroll area, but disable horizontal
// scrolling.
QScrollArea* plotArea = new QScrollArea;
//plotArea->setWidgetResizable(true);
//plotArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOf f);
splitter->addWidget(plotArea);
QVBoxLayout* plotLayout = new QVBoxLayout;
plotArea->setLayout(plotLayout);
// add some crap
for(int i = 0; i != 20; ++i)
(new QTreeWidgetItem(treeWidget))->setText(0, "Test " + QString::number(i));
}
MainWindow::~MainWindow()
{
delete ui;
}
To copy to clipboard, switch view to plain text mode
*
Bookmarks