QCustomPlot Discussion and Comments

Why the API Doc is so painful to read... please help!Return to overview

Gosh, it is so painful to read the API documentation because it lacks of good example and picture to explain the terminology. 95% of the time I just don't understand it. When I think I do and try to program with it I end up with unpredictable result!

This time I am struggling with setHorizontalSpacing, setVerticalSpacing, setColumnStretch, setMaximumWidth, setMinimumWidth. Please help me out.

My goal is simple. I would like to understand how the above functions works by just trying it out since the API doc is not doing a good job. I am trying to create a 3x10 table with QLabel, then realign the column and row spacing to make it looks nice. However, the column/row spacing are just unpredictable and I have no idea on how to fix it. Please help.


	QGridLayout *qLayout = new QGridLayout( MainWindow->my_GroupBox );

	qLayout->setHorizontalSpacing(10);     //tried 0-50 but the distance between column is unpredictable
	qLayout->setVerticalSpacing(0);        //tried 0-50 but it does not change the distance between rows
	qLayout->setColumnStretch(2,1);        //still have no idea how to take advantage of this function

	QLabel *lbl = new QLabel("Width");
	lbl->setMaximumWidth(25);              //tried 5-50 but the distance between column is unpredictable
	qLayout->addWidget(lbl, 0, 0);

	lbl = new QLabel("Height");
	lbl->setMinimumWidth(25);              //tried 5-50 but the distance between column is unpredictable
	qLayout->addWidget(lbl, 0, 1);

	lbl = new QLabel("Area");
	lbl->setMinimumWidth(25);              //tried 5-50 but the distance between column is unpredictable
	qLayout->addWidget(lbl, 0, 2);


	//Populate data for Channel, Error Count, Error Volume
	for (int i=0; i<10; ++i)
	{
		lbldata[0][i] = new QLabel(tr("%1").arg(i*.25));
		lbldata[0][i]->setMinimumWidth(25);                //tried 5-50 but the distance between column is unpredictable
		qLayout->addWidget(lbldata[0][i], i+1, 0);

		lbldata[1][i] = new QLabel(tr("%1").arg(i*5));
		lbldata[1][i]->setMinimumWidth(25);                //tried 5-50 but the distance between column is unpredictable
		qLayout->addWidget(lbldata[1][i], i+1, 1);

		lbldata[2][i] = new QLabel(tr("%1").arg(i*i*.25*5));
		lbldata[2][i]->setMinimumWidth(25);                //tried 5-50 but the distance between column is unpredictable
		qLayout->addWidget(lbldata[2][i], i+1, 2);
	}

You do realize that this has nothing to do with QCustomPlot, right? This is purely Qt, QGridLayout and QLabel are Qt widgets. Please make yourself familiar with the Qt terminology and documentation and, if necessary, ask in Qt forums about it.
Since most people consider the Qt documentation to be one of the best framework documentations around, I think you just need some more time to get accustomed to it.

Yes, I just realize about it about posting the message. It is the Qt framework, not QCustomPlot. Thanks