QTabWidget example
-
Hello all,
Is there a QTabWidget example? One that programmaticly creates the control and places an edit box, a check box a button or something in some of the tabs?I am able to create the tab control but I don’t see my edit boxes.
TABCTRLConversion=new QTabWidget(this);
//Position the control
TABCTRLConversion->setGeometry(5, 450, 500, 500);//We have to create a widget for each tab
WIDGETTemperature=new QWidget(NULL);tempString="Temperature";
TABCTRLConversion->addTab(WIDGETTemperature, tempString);
WIDGETWeight1=new QWidget(NULL);
tempString="Weight";
TABCTRLConversion->addTab(WIDGETWeight1, tempString);
WIDGETWeight2=new QWidget(NULL);
tempString="Weight2";
TABCTRLConversion->addTab(WIDGETWeight2, tempString);
connect(TABCTRLConversion, SIGNAL(currentChanged(sint)), this, SLOT(OnSelchangeTabConversion(sint)));xSPosition1=30;
yPosition1=500;
yOffset1=50;
yOffset2=22;
EDITBOXCelsiusSize=71;
STATICTemperature1=new QLabel(WIDGETTemperature);
//Position the control
STATICTemperature1->setGeometry(xSPosition1, yPosition1-yOffset2, 171, 22);
STATICTemperature1->setText(tr("Convert °F to °C and K"));
EDITFahrenheit=new QLineEdit(WIDGETTemperature);
//Position the control
EDITFahrenheit->setGeometry(xSPosition1, yPosition1, EDITBOXCelsiusSize, 22);
EDITFahrenheit->setMaxLength(50);
connect(EDITFahrenheit, SIGNAL(textChanged(QString)), this, SLOT(OnChangeEditFahrenheit(QString))); -
@stretchthebits
I don't know whether your code does not work. One simply creates aQWidget
for each "page", and put that into theQTabWidget
viaaddTab()
, as you seem to have done.Then, like any other
QWidget
, each of those page widgets should have aQLayout
, and you add your sub-controls onto the page layouts as usual. -
@stretchthebits said in QTabWidget example:
SIGNAL(currentChanged(sint))
There is no such signal in QTabWidget - this is also printed during runtime on the console.
And please use the new signal/slot syntax - then you can't hit such problems anymore. -
@Christian-Ehrlicher
Thanks, I changed that part to
connect(TABCTRLConversion, &QTabWidget::currentChanged, this, &CChemicalADlg::OnSelchangeTabConversion);and it worked. One problem solved. One more to go.
-
@stretchthebits Then please mark the topic as solved, thx.