Jump to content
  • Advertisement
Sign in to follow this  

Qt - Resizing issues, minimum size seems to be ignored

This topic is 847 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.
Here is the relevant code for my HeaderDataBrowser widget (this is added as a child to the QTabWidget):

HeaderDataBrowser::HeaderDataBrowser(QWidget* parent) :
	// Header data tree goes on the left side, TxSeq plots on the right
	QVBoxLayout* browserLayout = new QVBoxLayout;
	QSplitter* splitter = new QSplitter(this);

	// 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;
	QVBoxLayout* scrollLayout = new QVBoxLayout;
	treeWidget_ = new QTreeWidget;

	// 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;
	plotLayout_ = new QVBoxLayout;

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

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

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

	// 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
Sign in to follow this  

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!