The Ultimate Qt Community site
Home News Forum Wiki Contest FAQ Links

Go Back   Qt Centre Forum > Qt > Qt Programming

Qt Programming General Qt programming issues.

Reply
 
Thread Tools Search this Thread Display Modes
  #21  
Old 25th June 2008, 03:22
Fatla Fatla is offline
Novice
 
Join Date: Jun 2008
Qt products used: Qt4, Qt/Embedded
Qt platforms used: Windows
Posts: 35
Thanks: 5
Thanked 2 Times in 2 Posts
Default Re: Allow Many QWidgets to be Shown into One QWidget ?

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:
  1. #include "Container.h"
  2.  
  3.  
  4.  
  5. Container::Container(QWidget *parent): QWidget(parent)
  6.  {
  7.     ContainerUi.setupUi(this);
  8.  
  9.     PageIndex=1;
  10.    
  11.    
  12.     CustomSlot1 *CustomSlot1Obj =new CustomSlot1();
  13.     CustomSlot2 *CustomSlot2Obj=new CustomSlot12();
  14.     CustomSlot3 *CustomSlot3Obj=new CustomSlot3();
  15. //........................ to CustomSlot9
  16.  
  17.  
  18.     // Push objects into the QStackedWidget
  19.     ContainerUi.StackedWidget->addWidget(CustomSlot1);
  20.     ContainerUi.StackedWidget->addWidget(CustomSlot2);
  21.     ContainerUi.StackedWidget->addWidget(CustomSlot3);
  22. //.................. pust the other Widgets into the Stack
  23.  
  24.  
  25.     ContainerUi.StackedWidget->setCurrentIndex(PageIndex);
  26.     PageIndex++;
  27.  
  28. }
  29.  
  30. void Container :: NextPage()
  31. {
  32.    
  33.  
  34.  
  35.     int CurrentIndex=ContainerUi.StackedWidget->currentIndex ();
  36.     if(PageIndex <10)
  37.     {
  38.        
  39.         if(CurrentIndex==3 )
  40.         {
  41.         CustomSLot3 *widget ;
  42.         widget=ContainerUi.StackedWidget->widget  (3);
  43.                                   // GrainSizeFlag is a public variable at CustomSlot3
  44.                 if(widget->GrainSizeFlag==true)
  45.                 ::PageIndex=7;
  46.            
  47.            
  48.            
  49.         }
  50.         ContainerUi.StackedWidget->setCurrentIndex(PageIndex);
  51.         PageIndex++;
  52.  
  53.     }
  54.  
  55.  
  56. }
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 .

Reply With Quote
  #22  
Old 25th June 2008, 07:30
wysota wysota is offline
Guru
 
Join Date: Jan 2006
Location: Warsaw, Poland
Qt products used: Qt3, Qt4
Qt platforms used: Unix/X11, Windows
Posts: 11,286
Thanks: 3
Thanked 1,589 Times in 1,541 Posts
Default Re: Allow Many QWidgets to be Shown into One QWidget ?

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).

Reply With Quote
  #23  
Old 4th July 2008, 23:01
Fatla Fatla is offline
Novice
 
Join Date: Jun 2008
Qt products used: Qt4, Qt/Embedded
Qt platforms used: Windows
Posts: 35
Thanks: 5
Thanked 2 Times in 2 Posts
Default Re: Allow Many QWidgets to be Shown into One QWidget ?

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 .

Reply With Quote
  #24  
Old 5th July 2008, 13:15
Fatla Fatla is offline
Novice
 
Join Date: Jun 2008
Qt products used: Qt4, Qt/Embedded
Qt platforms used: Windows
Posts: 35
Thanks: 5
Thanked 2 Times in 2 Posts
Default Re: Allow Many QWidgets to be Shown into One QWidget ?

I've found a solution to the problem :

Qt Code:
  1. this->setEnabled(false);
  2.  
  3.    HMENU menu = ::GetSystemMenu(this->winId(), FALSE);
  4.  
  5.    ::DeleteMenu(menu, SC_CLOSE, MF_BYCOMMAND);
  6.  
  7.    ::EnableMenuItem(menu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
That of course after including : #include <qt_windows.h>

Reply With Quote
  #25  
Old 5th July 2008, 16:06
Fatla Fatla is offline
Novice
 
Join Date: Jun 2008
Qt products used: Qt4, Qt/Embedded
Qt platforms used: Windows
Posts: 35
Thanks: 5
Thanked 2 Times in 2 Posts
Default Re: Allow Many QWidgets to be Shown into One QWidget ?

Now I've 2 issues :
1- How could I also disable "Maximize" & "Minimize" ?
2- How could I enable them after I've just disabled them ?


Thanks .

Reply With Quote
  #26  
Old 5th July 2008, 21:14
Fatla Fatla is offline
Novice
 
Join Date: Jun 2008
Qt products used: Qt4, Qt/Embedded
Qt platforms used: Windows
Posts: 35
Thanks: 5
Thanked 2 Times in 2 Posts
Default Re: Allow Many QWidgets to be Shown into One QWidget ?

I've solved the 2nd issue by :

Qt Code:
  1. void MainWindow::EnableToolBar()
  2.  {
  3.      MainWindowMenu = ::GetSystemMenu(this->winId(), TRUE);
  4.  
  5.  }

Reply With Quote
  #27  
Old 6th July 2008, 09:29
wysota wysota is offline
Guru
 
Join Date: Jan 2006
Location: Warsaw, Poland
Qt products used: Qt3, Qt4
Qt platforms used: Unix/X11, Windows
Posts: 11,286
Thanks: 3
Thanked 1,589 Times in 1,541 Posts
Default Re: Allow Many QWidgets to be Shown into One QWidget ?

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)).

Reply With Quote
The following user says thank you to wysota for this useful post:
Fatla (23rd July 2008)
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Error in put one QWidget in another QWidget xjtu Qt Programming 1 19th April 2008 16:05
Keeping QWidgets as private QWIdget subclass members mtrpoland Newbie 2 1st January 2008 13:31


All times are GMT +1. The time now is 05:58.

Powered by vBulletin Version 3.7.1 Copyright ©2000 - 2008, Jelsoft Enterprises Ltd., vRewrite 1.5 SEOed URLs completed by Tech Help Forum and Chalo Na.
© 2006–2008 Qt Centre - The Ultimate Qt Community site
Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.