Hey guys,
I am trying to have a common widget which is going to appear on several pages of a stackedwidget. In my example below, I did not connect the pushButtons but assume that pushButton1 will ask mStacked to show the first widget while pushButton2 will ask mStacked to show the second widget.
I've been declaring a few widgets as follows:
Note: Not complete code, but you get the idea.
Qt Code:
{ mStacked->addWidget( commonWidget() ); //Declaration of Page 1 mStacked->addWidget( commonWidget() ); //Declaration of Page 2 mainLayout->addWidget(mStacked); mainLayout->addWidget(pushButton1); mainLayout->addWidget(pushButton2); setLayout(mainLayout); } { layout->addWidget(mLabel); mWidget->setLayout(layout); return mWidget; }To copy to clipboard, switch view to plain text mode
I have two main questions:
1. Is this a good way of declaring a commonWidget?
2. If it's the usual way, is there a way to ensure that only one instance of mLabel is created? In otherwords, when I change the value of mLabel on one page, the same value is displayed on the other pages.
Thanks much.
Regards,
Pembar
Bookmarks