Jump to content
  • Advertisement
Sign in to follow this  
TheComet

Qt - Resizing issues, minimum size seems to be ignored

This topic is 1001 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have created a Qt application with the following structure:
 
.
??? QMdiArea
    ??? QTabWidget
        ??? HeaderDataBrowser
            ??? QVBoxLayout
                ??? QSplitter
                    ??? QScrollArea1
                    ?   ??? QVBoxLayout
                    ?       ??? QTreeWidget
                    ??? QScrollArea2
                        ??? QVBoxLayout
                            ??? QwtPlot1
                            ??? QwtPlot2
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.
 
[media]https:
[/media]
 
Here is the relevant code for my HeaderDataBrowser widget (this is added as a child to the QTabWidget):
 

 
HeaderDataBrowser::HeaderDataBrowser(QWidget* parent) :
	QWidget(parent),
	treeWidget_(NULL),
	plotLayout_(NULL)
{
	// Header data tree goes on the left side, TxSeq plots on the right
	QVBoxLayout* browserLayout = new QVBoxLayout;
	QSplitter* splitter = new QSplitter(this);
	browserLayout->addWidget(splitter);
	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);
	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::ScrollBarAlwaysOff);
	splitter->addWidget(plotArea);
	plotLayout_ = new QVBoxLayout;
	plotArea->setLayout(plotLayout_);
}
 

// ----------------------------------------------------------------------------
QwtPlot* HeaderDataBrowser::addPlot()
{
	QwtPlot* plot = new QwtPlot;
	plot->setTitle("Tx Sequence");
	plot->setMinimumSize(100, 100);
	plotLayout_->addWidget(plot);

	// Add a dotted grid
	QwtPlotGrid* plotGrid = new QwtPlotGrid;
	plotGrid->enableX(true);
	plotGrid->enableY(true);
	plotGrid->setMajorPen(QPen(Qt::black, 0, Qt::DotLine));
	plotGrid->setMinorPen(QPen(Qt::gray,  0, Qt::DotLine));
	plotGrid->attach(plot);

	// Legend
	QwtPlotLegendItem* legend = new QwtPlotLegendItem;
	legend->setAlignment(Qt::AlignRight | Qt::AlignTop);
	legend->attach(plot);

	// Axis titles
	plot->setAxisTitle(QwtPlot::yLeft, "Amplitude");
	plot->setAxisTitle(QwtPlot::xBottom, "Time");

	return plot;
}
Edited by TheComet

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!