PDA

View Full Version : how to interact with tabs in qt



rahulgogoi
8th August 2011, 06:54
Actually i have created three tabs in my app..now on selecting each tab i want to open a new form on that particular tab..the code i have written for creating tabs...


tabWidget = new QTabWidget;
QWidget* pCalender = new QWidget;
QWidget* pHistory = new QWidget;
QWidget* pStatistics= new QWidget;
tabWidget->addTab(pCalender,tr("Calender"));
tabWidget->addTab(pHistory,tr("History"));
tabWidget->addTab(pStatistics,tr("Statistics"));

now i have three forms.

1.calendar.cpp

2.history.cpp

3.statistic.cpp

now what i want is onclick of each tab i want to open each of the form in particular tab...ie calendar form on tab1...history form on tab2 and statistic form on tab 3..so anyone please suggest me how that can be done...

with regards
Rahul

marcvanriet
8th August 2011, 12:24
Hi,
See this thread : QStackedWidget-and-QTabWidget-Structure-Advice (http://www.qtcentre.org/threads/36032-QStackedWidget-and-QTabWidget-Structure-Advice).

It does what you want I think : you have different forms created somehow, and you want each to show in a page of a tab sheet.

Note that for simple tabs, you can just add all your widgets to the QTabWidget that is returned by addTab. Or just use Qt Designer, define some tab pages, and drag the widgets onto the tab pages.

Best regards,
Marc