Page 1 of 2 12 LastLast
Results 1 to 20 of 27

Thread: Allow Many QWidgets to be Shown into One QWidget ?

  1. #1
    Join Date
    Jun 2008
    Posts
    35
    Thanks
    5
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Question Allow Many QWidgets to be Shown into One QWidget ?

    I've created Many (.UI) , made a (Header File + .cpp) to each .UI in order to implement their own slots , & Linked them by making a widget to be shown using :
    Qt Code:
    1. // CustomSlot2 implements the slots inside the 2nd .UI
    2. CustomSlot2* widget = new CustomSlot2();
    3. widget->setAttribute(Qt::WA_DeleteOnClose);
    4. widget->show();
    To copy to clipboard, switch view to plain text mode 

    CustomSlot2 Constructor's Code is :
    Qt Code:
    1. CustomSlot2::CustomSlot2(QWidget *parent): QWidget(parent)
    2. {
    3. formTwo.setupUi(this);
    4.  
    5. }
    To copy to clipboard, switch view to plain text mode 

    So far so Good . However , by making this approach there's a flicker when you Open & Hide/Close Windows .
    I've thought in an alternative way ;that I'll Drag & Drop a QWidget into my Main Window using QT Design.
    The Problem : How Could I open my .UIs into the QWidget that I've added @ MainWindow .

    The MainWindow's header file generated by "make" :

    Qt Code:
    1. class Ui_MainForm
    2. {
    3. public:
    4. QPushButton *btnProcess;
    5. QLineEdit *txtInput;
    6. QLineEdit *txtResult;
    7. QPushButton *btnNext;
    8. QWidget *widget;
    9. //........................ etc
    To copy to clipboard, switch view to plain text mode 

    Thanks .

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Allow Many QWidgets to be Shown into One QWidget ?

    The ui must be creating classes for you, isnt it ?
    well add those classes/windows into ur main window as u would add a widget...
    hope i understand what you meant

  3. #3
    Join Date
    Jun 2008
    Posts
    35
    Thanks
    5
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Allow Many QWidgets to be Shown into One QWidget ?

    well add those classes/windows into ur main window as u would add a widget...
    How could I make all the .UIs show in the same Widget @ Main Window ?

    hope i understand what you meant
    Actually , It's My mistake that I didn't clarify my Problem well .
    So , Let me clarify it again ;
    Now , I'm @ QT Design then I create a normal widget ,add ctrls into it.
    I make the previous step 4 times . So now I've 4 .UIs that have there own ctrls into it .
    To Each UI, I create its (.h + .cpp ) to implement my own slots .
    Well now I open ,using QT Design ,the 1st .ui I 've made & Drag & Drop Widget into it , which is located into Container Section .
    The Problem : is how to make other .UIs open into the widget I created @ the 1st .ui I 've made .

    Thanks .

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Allow Many QWidgets to be Shown into One QWidget ?

    You can add a plain QWidget on the form and promote it as a custom widget (which loads another ui).
    J-P Nurmi

  5. #5
    Join Date
    Jun 2008
    Posts
    35
    Thanks
    5
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Allow Many QWidgets to be Shown into One QWidget ?

    Thanks aamer4yu.
    Perfect jpn .

    It works now after using Promoting .
    @ the MainWindow I've added a plain QWidget into it .
    I've noticed that its header file generated by "make" creates instance of CustomSlot (which implements the slots of the form appears into the plain widget @ MainWindow form .

    The Problem :now I want to replace the .UI that opened into the plain widget @ MainWindow with another .UI @ SAme plain Widget


    Header File's code generated of MainWindow that Contains the plain widget :

    Qt Code:
    1. class Ui_MainForm
    2. {
    3. public:
    4. CustomSlot *MiniWidget; // MiniWidget = The Plain widget
    5.  
    6. void setupUi(QWidget *MainForm)
    7. {
    8. if (MainForm->objectName().isEmpty())
    9. MainForm->setObjectName(QString::fromUtf8("MainForm"));
    10. MainForm->resize(530, 402);
    11. MiniWidget = new CustomSlot(MainForm);
    12. MiniWidget->setObjectName(QString::fromUtf8("MiniWidget"));
    13. MiniWidget->setGeometry(QRect(39, 29, 451, 301));
    14.  
    15. retranslateUi(MainForm);
    16.  
    17. QMetaObject::connectSlotsByName(MainForm);
    18. } // setupUi
    19.  
    20. void retranslateUi(QWidget *MainForm)
    21. {
    22. MainForm->setWindowTitle(QApplication::translate("MainForm", "Main Form", 0, QApplication::UnicodeUTF8));
    23. Q_UNUSED(MainForm);
    24. } // retranslateUi
    25.  
    26. };
    27.  
    28. namespace Ui {
    29. class MainForm: public Ui_MainForm {};
    30. } // namespace Ui
    31.  
    32. QT_END_NAMESPACE
    33.  
    34. #endif // UI_MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 

    Main.cpp 's code :

    Qt Code:
    1. #include <QApplication>
    2. #include "ui_MainWindow.h"
    3. #include "MainApp.cpp"
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication app(argc, argv);
    8.  
    9. MainApp widget;
    10. widget.show();
    11.  
    12. return app.exec();
    13.  
    14.  
    15. }
    To copy to clipboard, switch view to plain text mode 

    The MainApp's code that implements slots of the MainWindow :
    Qt Code:
    1. MainApp::MainApp(QWidget *parent): QWidget(parent)
    2. {
    3. ui.setupUi(this);
    4. }
    To copy to clipboard, switch view to plain text mode 

    Thanks

  6. #6
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Allow Many QWidgets to be Shown into One QWidget ?

    What do u mean replace ? If you mean to show another widget in same area, you can have a look at QStackedWidget. It allows you to show one widget at a time in the same area

  7. #7
    Join Date
    Jun 2008
    Posts
    35
    Thanks
    5
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Allow Many QWidgets to be Shown into One QWidget ?

    So , do you mean that there 's NO Way to use the plain widget to solve my problem ?!!
    Mmmm what about using many plain widgets @ the MainWindow & specify each one of them to a .ui ?!!
    If I follow that way , how could I ctrl in showing & closing/hiding the plain widgets ?

    Thanks

  8. #8
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Allow Many QWidgets to be Shown into One QWidget ?

    Just place a stacked widget on your form as proposed. Then make each page of the stack contain a different custom widget (which all load their own ui files). Switching from one custom widget to another is only a matter of switching the current widget in the stack.
    J-P Nurmi

  9. #9
    Join Date
    Jun 2008
    Posts
    35
    Thanks
    5
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Allow Many QWidgets to be Shown into One QWidget ?

    Quote Originally Posted by jpn View Post
    Just place a stacked widget on your form as proposed. Then make each page of the stack contain a different custom widget (which all load their own ui files). Switching from one custom widget to another is only a matter of switching the current widget in the stack.
    Actually I put set of plain widgets over each other @ my MainWindow .
    Then I promote each one to the proper .ui .
    Then @ my main : I've created instance of QStackedWidget & put into it the plain widgets that I've just created .

    Problems :
    - Program doesn't run even an .exe is generated + Exception is appeared
    - I was thinking that after creating my instance of StackedObject, I'll use it to ctrl which UI is going to be appeared , How could I achieve smth like that ?!!

    My Main 's code :
    Qt Code:
    1. #include <QApplication>
    2. #include "ui_MainWindow.h"
    3. #include "MainApp.cpp"
    4. #include <QStackedWidget>
    5.  
    6.  
    7. int main(int argc, char *argv[])
    8. {
    9. QApplication app(argc, argv);
    10.  
    11. QStackedWidget *StackedWidget = new QStackedWidget;
    12. Ui_MainForm ui;
    13.  
    14. StackedWidget->addWidget(ui.MiniWidget);
    15. StackedWidget->addWidget(ui.MiniWidget2);
    16.  
    17. MainApp Widget;
    18. Widget.show();
    19. return app.exec();
    20.  
    21. }
    To copy to clipboard, switch view to plain text mode 

    -------------------------------------------------------------------------
    MainWindow's generated code that contains the plain widgetS :

    Qt Code:
    1. #ifndef UI_MAINWINDOW_H
    2. #define UI_MAINWINDOW_H
    3.  
    4. #include <QtCore/QVariant>
    5. #include <QtGui/QAction>
    6. #include <QtGui/QApplication>
    7. #include <QtGui/QButtonGroup>
    8. #include <QtGui/QWidget>
    9. #include <customslot2.h>
    10. #include "customslot.h"
    11.  
    12. QT_BEGIN_NAMESPACE
    13.  
    14. class Ui_MainForm
    15. {
    16. public:
    17. // These are the Plain Widgets I created
    18. CustomSlot *MiniWidget;
    19. CustomSlot2 *MiniWidget2;
    20.  
    21. void setupUi(QWidget *MainForm)
    22. {
    23. if (MainForm->objectName().isEmpty())
    24. MainForm->setObjectName(QString::fromUtf8("MainForm"));
    25. MainForm->resize(530, 402);
    26. MiniWidget = new CustomSlot(MainForm);
    27. MiniWidget->setObjectName(QString::fromUtf8("MiniWidget"));
    28. MiniWidget->setGeometry(QRect(39, 29, 451, 301));
    29. MiniWidget2 = new CustomSlot2(MiniWidget);
    30. MiniWidget2->setObjectName(QString::fromUtf8("MiniWidget2"));
    31. MiniWidget2->setGeometry(QRect(0, 110, 461, 301));
    32.  
    33. retranslateUi(MainForm);
    34.  
    35. QMetaObject::connectSlotsByName(MainForm);
    36. } // setupUi
    37.  
    38. void retranslateUi(QWidget *MainForm)
    39. {
    40. MainForm->setWindowTitle(QApplication::translate("MainForm", "Main Form", 0, QApplication::UnicodeUTF8));
    41. Q_UNUSED(MainForm);
    42. } // retranslateUi
    43.  
    44. };
    45.  
    46. namespace Ui {
    47. class MainForm: public Ui_MainForm {};
    48. } // namespace Ui
    49.  
    50. QT_END_NAMESPACE
    51.  
    52. #endif // UI_MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 

    Thanks

  10. #10
    Join Date
    Jun 2008
    Posts
    35
    Thanks
    5
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Allow Many QWidgets to be Shown into One QWidget ?

    I've tried many times to use QStackedWidget . However , I'm facing a few difficulties with it .
    Problem : How Could I use it into my app ,mentioned b4 ?!!

  11. #11
    Join Date
    Jun 2008
    Posts
    35
    Thanks
    5
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Allow Many QWidgets to be Shown into One QWidget ?

    I've made a little progress .
    I've just noticed that there's @ QT Design smth called "stacked Widget" .

    I 've promoted to the Stacked Widget one of my .UI .

    Problem :
    - I got an error : 'class CustomSlot' has no member named 'addWidget' ?!!
    - I 've noticed that I can add any number of pages @ Stacked Widget , so How Can I promote different .UI , to each page I 've ?

    Header File 's code that has the custom Widget

    Qt Code:
    1. #ifndef UI_FORM2_H
    2. #define UI_FORM2_H
    3.  
    4. #include <QtCore/QVariant>
    5. #include <QtGui/QAction>
    6. #include <QtGui/QApplication>
    7. #include <QtGui/QButtonGroup>
    8. #include <QtGui/QGroupBox>
    9. #include <QtGui/QLabel>
    10. #include <QtGui/QLineEdit>
    11. #include <QtGui/QPushButton>
    12. #include <QtGui/QRadioButton>
    13. #include <QtGui/QTableView>
    14. #include <QtGui/QWidget>
    15. #include <customslot.h>
    16.  
    17. QT_BEGIN_NAMESPACE
    18.  
    19. class Ui_FormTWo
    20. {
    21. public:
    22. QPushButton *btnGender;
    23. QGroupBox *gpBoxGender;
    24. QRadioButton *rdBtnMale;
    25. QRadioButton *rdBtnFemale;
    26. QLabel *lblSelectedFilePath;
    27. QPushButton *btnBrowse;
    28. QPushButton *pushButton;
    29. QLineEdit *txtFileData;
    30. QPushButton *pushButton_2;
    31. QPushButton *btnReadImage;
    32. QTableView *TableViewData;
    33. QPushButton *btnSaveAs;
    34. CustomSlot *stackedWidget;
    35. QWidget *Form1;
    36. QWidget *Form2;
    37.  
    38. void setupUi(QWidget *FormTwo)
    39. {
    40. stackedWidget = new CustomSlot(FormTwo);
    41. stackedWidget->setObjectName(QString::fromUtf8("stackedWidget"));
    42. stackedWidget->setGeometry(QRect(540, 230, 171, 131));
    43. Form1 = new QWidget();
    44. Form1->setObjectName(QString::fromUtf8("Form1"));
    45. Form1->setGeometry(QRect(0, 0, 171, 131));
    46. stackedWidget->addWidget(Form1);
    47. Form2 = new QWidget();
    48. Form2->setObjectName(QString::fromUtf8("Form2"));
    49. Form2->setGeometry(QRect(0, 0, 171, 131));
    50. stackedWidget->addWidget(Form2);
    51.  
    52. retranslateUi(FormTwo);
    53.  
    54. stackedWidget->setCurrentIndex(0);
    55.  
    56.  
    57.  
    58. } // setupUi
    59.  
    60. void retranslateUi(QWidget *FormTanya)
    61. {
    62. // ...........................etc
    63. } // retranslateUi
    64.  
    65. };
    66.  
    67. namespace Ui {
    68. class FormTwo: public Ui_FormTwo {};
    69. } // namespace Ui
    70.  
    71. QT_END_NAMESPACE
    72.  
    73. #endif // UI_FORM2_H
    To copy to clipboard, switch view to plain text mode 

    ---------------------------------------------------------------------------------
    My CustomSlot 's code :
    Qt Code:
    1. #include"CustomSlot.h"
    2. #include "ui_Test.h"
    3.  
    4. #include "ui_Form2.h"
    5. #include"CustomSlot2.cpp"
    6.  
    7.  
    8.  
    9. CustomSlot::CustomSlot(QWidget *parent): QWidget(parent)
    10. {
    11. ui.setupUi(this);
    12. }
    13. // ......................etc
    To copy to clipboard, switch view to plain text mode 

    Thanks .

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Allow Many QWidgets to be Shown into One QWidget ?

    Please use proper language instead of sms slang. And please read QStackedWidget docs, by the way Promoting widgets is not the same as placing one widget in another and I think you are mixing the two.

  13. #13
    Join Date
    Jun 2008
    Posts
    35
    Thanks
    5
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Allow Many QWidgets to be Shown into One QWidget ?

    Quote Originally Posted by wysota View Post
    Promoting widgets is not the same as placing one widget in another and I think you are mixing the two.
    YES I WAS .
    I'd already read the QStackedWidget from the docs b4 many times . However after what you 'd just told me , things become more clear now .

    I've made a simple app that just contains : Button + Custom Widget (Dragged & Dropped using QT Desgin)

    I want each time the user clicks the button , different .UIs to be shown .

    Problem :
    -Every time I run the app , Exception is appeared
    -I just added these line at my main :

    Qt Code:
    1. Ui_FormTwo FormTwoObj; // UI that contains my Stacked Widget
    2.  
    3. CustomSlot *CustomSlotObj; // The class that implements slots of UI I want to display to the user
    4.  
    5. FormTwo.stackedWidget->addWidget(CustomSlotObj);
    To copy to clipboard, switch view to plain text mode 

    - I Still don't understand well the QStackedWidget . What I Understand that QStackedWidget is a stack that you can push & pop like the normal stack with the capability of controlling with the index of Removing / Wanted objects in the stack .
    So now How could I make an object at stack to be appeared to the user ?

    Quote Originally Posted by wysota View Post
    Please use proper language instead of sms slang.
    Thanks for notifying me


    Thanks .

  14. #14
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Allow Many QWidgets to be Shown into One QWidget ?

    Treat the stacked widget as a book where you can add or remove pages (but this is not the important part here) and where you can open the book at any page at any moment and view that page (that's the important part) and only that page.

  15. #15
    Join Date
    Jun 2008
    Posts
    35
    Thanks
    5
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Allow Many QWidgets to be Shown into One QWidget ?

    That's Wonderful .
    1/2 of my problem 's been solved .

    I've just noticed that when I drag & drop QStackedWidget using QT Design , Pages (instance of Widgets ) are created & added to the stacked widget .
    I can add any number of pages I want & add the controls into it . I can control which widget to be displayed .
    It works so great .

    The second half of my problem :
    - Whenever I try to declare instace of my .UI & add it to the QStackedWidget , Exception is appeared .
    I've tried :
    addWidget(WidgetObj);
    widget(index );
    insertWidget (index , WidgetObj);

    CustomSlot's code that implements slots of the .UI & also has the QStackedWidget :

    Qt Code:
    1. #include"CustomSlot2.h"
    2. #include "ui_Form2.h"
    3. #include "CustomSlot.h"
    4.  
    5.  
    6.  
    7. CustomSlot2::CustomSlot2(QWidget *parent): QWidget(parent)
    8. {
    9. formTwo.setupUi(this);
    10.  
    11. //CustomSlot is the class that implement the slots of the .UI that I want to add at QStackedWidget
    12. CustomSlot *CustomSlotObj ;
    13. //formTwo.stackedWidget->addWidget(CustomSlotObj);
    14.  
    15. // I've already just 2 pages at QStackedWidget , The third on is going to be in index 2
    16. formTwo.stackedWidget->insertWidget(2,CustomSlotObj);
    17.  
    18. QWidget *WidgetObj;
    19. WidgetObj= formTwo.stackedWidget->widget (2) ;
    20.  
    21.  
    22. WidgetObj->show();
    23.  
    24.  
    25. }
    To copy to clipboard, switch view to plain text mode 


    Thanks .

  16. #16
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Allow Many QWidgets to be Shown into One QWidget ?

    "CustomSlot *CustomSlotObj;" produces nothing but a dangling pointer which points to some random memory garbage. You forgot to actually instantiate something with C++ operator new.
    J-P Nurmi

  17. #17
    Join Date
    Jun 2008
    Posts
    35
    Thanks
    5
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Allow Many QWidgets to be Shown into One QWidget ?

    Perfect , it works now .
    However I still have simple issues :

    1- When I add my .UI at the QStacked Widget , it successfully appears & I can just control it using Keyboard (i.e. the UI that I've added at QStacked Widget contains QLineEdit + Button I can't press the button using the mouse I should use my "Tab" in order to go to that control then press "Space" ) ?!!

    2- According to what I've have understood that only one widget at QStackedWidget can be displayed at once to the user .
    I just have one QWidget that is put by default at QStackedWidget , when I drag & drop the stack using QT Design . Then at this page I've added a button . Then using the code I 've added my .UI at the stack then show it .
    What 's weird : that both QWidgets that have the button + the other Widget that I 've add by code are displayed ?

    Thanks .

  18. #18
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Allow Many QWidgets to be Shown into One QWidget ?

    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

  19. #19
    Join Date
    Jun 2008
    Posts
    35
    Thanks
    5
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Allow Many QWidgets to be Shown into One QWidget ?

    How is that ?!!

    Part of Header files 's code generated to the form that contains the QStackedWidget :

    Qt Code:
    1. #include <QtGui/QStackedWidget>
    2. #include <QtGui/QWidget>
    3.  
    4.  
    5. class Ui_FormTwo
    6. {
    7. public:
    8. QStackedWidget *stackedWidget;
    9. QWidget *page;
    10.  
    11. void setupUi(QWidget *FormTwo)
    12. {
    13. stackedWidget = new QStackedWidget(FormTwo);
    14. stackedWidget->setObjectName(QString::fromUtf8("stackedWidget"));
    15. stackedWidget->setGeometry(QRect(460, 130, 551, 371));
    16. page = new QWidget();
    17. page->setObjectName(QString::fromUtf8("page"));
    18. page->setGeometry(QRect(0, 0, 551, 371));
    19. stackedWidget->addWidget(page);
    20.  
    21. retranslateUi(FormTwo);
    22.  
    23. stackedWidget->setCurrentIndex(0);
    24.  
    25. // ......................etc
    26.  
    27. } // setupUi
    To 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:
    1. CustomSlot2::CustomSlot2(QWidget *parent): QWidget(parent)
    2. {
    3. formTwo.setupUi(this);
    4.  
    5. CustomSlot *CustomSlotObj=new CustomSlot() ;
    6.  
    7. formTwo.stackedWidget->insertWidget(1,CustomSlotObj);
    8.  
    9. QWidget *WidgetObj;
    10. WidgetObj= formTwo.stackedWidget->widget (1) ;
    11.  
    12. WidgetObj->show();
    13.  
    14.  
    15. }
    To copy to clipboard, switch view to plain text mode 

    Thanks .

  20. #20
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Allow Many QWidgets to be Shown into One QWidget ?

    Aha, now I realized what's wrong.
    Quote Originally Posted by Fatla View Post
    Qt Code:
    1. QWidget *WidgetObj;
    2. WidgetObj= formTwo.stackedWidget->widget (1) ;
    3.  
    4. WidgetObj->show();
    To copy to clipboard, switch view to plain text mode 
    This is not the way you use QStackedWidget. You are supposed to use QStackedWidget::setCurrentIndex() or setCurrentWidget().
    J-P Nurmi

Similar Threads

  1. Error in put one QWidget in another QWidget
    By xjtu in forum Qt Programming
    Replies: 1
    Last Post: 19th April 2008, 16:05
  2. Replies: 2
    Last Post: 1st January 2008, 13:31

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.