Sounds like you created the form as a child of the stacked widget but you didn't actually add the widget to the stack widget. That's at least one reason why it wouldn't be managed by the stacked widget.
Sounds like you created the form as a child of the stacked widget but you didn't actually add the widget to the stack widget. That's at least one reason why it wouldn't be managed by the stacked widget.
J-P Nurmi
How is that ?!!
Part of Header files 's code generated to the form that contains the QStackedWidget :
Qt Code:
#include <QtGui/QStackedWidget> #include <QtGui/QWidget> class Ui_FormTwo { public: QStackedWidget *stackedWidget; QWidget *page; { stackedWidget->addWidget(page); retranslateUi(FormTwo); stackedWidget->setCurrentIndex(0); // ......................etc } // setupUiTo copy to clipboard, switch view to plain text mode
---------------------------------------------------------------
Temporarily , I've added the code that add my .UI to the stack at the constructor of the form that has the stack object :
Qt Code:
{ formTwo.setupUi(this); CustomSlot *CustomSlotObj=new CustomSlot() ; formTwo.stackedWidget->insertWidget(1,CustomSlotObj); QWidget *WidgetObj; WidgetObj= formTwo.stackedWidget->widget (1) ; WidgetObj->show(); }To copy to clipboard, switch view to plain text mode
Thanks .
Thanks , it works successfully .
I 've one more question :
- I've added many QWidgets into stack . Now I need when the turn comes to a particular widget to be shown , I can access its variables .
Qt Code:
#include "Container.h" { ContainerUi.setupUi(this); PageIndex=1; CustomSlot1 *CustomSlot1Obj =new CustomSlot1(); CustomSlot2 *CustomSlot2Obj=new CustomSlot12(); CustomSlot3 *CustomSlot3Obj=new CustomSlot3(); //........................ to CustomSlot9 // Push objects into the QStackedWidget ContainerUi.StackedWidget->addWidget(CustomSlot1); ContainerUi.StackedWidget->addWidget(CustomSlot2); ContainerUi.StackedWidget->addWidget(CustomSlot3); //.................. pust the other Widgets into the Stack ContainerUi.StackedWidget->setCurrentIndex(PageIndex); PageIndex++; } void Container :: NextPage() { int CurrentIndex=ContainerUi.StackedWidget->currentIndex (); if(PageIndex <10) { if(CurrentIndex==3 ) { CustomSLot3 *widget ; widget=ContainerUi.StackedWidget->widget (3); // GrainSizeFlag is a public variable at CustomSlot3 if(widget->GrainSizeFlag==true) ::PageIndex=7; } ContainerUi.StackedWidget->setCurrentIndex(PageIndex); PageIndex++; } }To copy to clipboard, switch view to plain text mode
By default the Stack contains one widget . So my "CustomSlot" 'll go to the index [1].
As a result of that , CustomSlot3 'll go to index [3].
I've an error that tells ms : Invalid Conversion QWidget* to CustomSlot3*
Thanks .
I suggest you keep all pointers as member variables of the containing class and access them directly instead of fetching the pointer through current widget of the stack (it is possible of course - you'd have to cast the pointer received to a proper type).
It has been a long time since my last reply .
Things were going so fine & the resources over web were extremely helpful .
Currently , I was looking for property/function that DeActivate child widget
(e.g. If I've a Widget that has a QPushButton . When the user press that button another widget 'll be shown & TOTALLY DeActivate the previouse widget .
So the user won't be able even to close / maximize/minimize the old widget )
I've tried :
isActiveWindow():Just make the widget on top .
setEnabledisable all the controls into widget but not the toolbar (i.e. the user will be able to close / maximize/minimize widget)
Thanks .
I've found a solution to the problem :
Qt Code:
this->setEnabled(false); HMENU menu = ::GetSystemMenu(this->winId(), FALSE); ::DeleteMenu(menu, SC_CLOSE, MF_BYCOMMAND); ::EnableMenuItem(menu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);To copy to clipboard, switch view to plain text mode
That of course after including : #include <qt_windows.h>
I've solved the 2nd issue by :
Qt Code:
void MainWindow::EnableToolBar() { MainWindowMenu = ::GetSystemMenu(this->winId(), TRUE); }To copy to clipboard, switch view to plain text mode
Why would you want to disable maximizing/minimizing a window? Don't you think it is an extreme interference in the user's desktop? As for closing, you don't need any windows related functions, simply reimplement closeEvent() for your widget and ignore the event if you want to prevent the window from being closed. You can disable the maximize/minimize buttons if you really want to, by either hiding them using window flags or by removing the window from the window manager's control (by using window flags again). To disable the contents of a window simply disable() it (or setEnabled(false)).
Fatla (23rd July 2008)
Bookmarks