Results 1 to 16 of 16

Thread: How to develop a multi-gui application "alternative for the stacked widget "

  1. #1
    Join Date
    Feb 2013
    Location
    Banzart
    Posts
    54
    Thanks
    17
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Question How to develop a multi-gui application "alternative for the stacked widget "

    Hello i am a beginner my objective is to develop a multi interfaces application where each interface "widget" had it's own .cpp and .h files .
    my second question is how to link them up
    i want an application which is similar in the structure and the classes to an android application where each interface has it's specifics files
    Sliver_Twist

  2. #2
    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: How to develop a multi-gui application "alternative for the stacked widget "

    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Feb 2013
    Location
    Banzart
    Posts
    54
    Thanks
    17
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to develop a multi-gui application "alternative for the stacked widget "

    i know already that but the stackedwidget doesn't allow me to seperate the code of each page "widget" in a separated .cpp and .h file
    Sliver_Twist

  4. #4
    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: How to develop a multi-gui application "alternative for the stacked widget "

    Of course it allows you to implement the code of each page in a separate set of files.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Feb 2013
    Location
    Banzart
    Posts
    54
    Thanks
    17
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to develop a multi-gui application "alternative for the stacked widget "

    how is that ??? I have already tried it but when implement a new page in the QstackedWidget i don't get a new set of files for the new page
    Sliver_Twist

  6. #6
    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: How to develop a multi-gui application "alternative for the stacked widget "

    QStackedWidget::addWidget() -- this accepts pointer to a widget. Any widget. Implemented in any file.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Feb 2013
    Location
    Banzart
    Posts
    54
    Thanks
    17
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to develop a multi-gui application "alternative for the stacked widget "

    Sorry for asking again but i have a problem using this method
    i have created a new QtDesignerForm class called Widget2
    do i call this widget like this ??
    ui->stackedWidget->addWidget(Widget2 );
    Sliver_Twist

  8. #8
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to develop a multi-gui application "alternative for the stacked widget "

    do i call this widget like this ??
    ui->stackedWidget->addWidget(Widget2 );
    No. You do this:

    Qt Code:
    1. Widget2 * newWidget2 = new Widget2;
    2. ui->stackedWidget->addWidget( newWidget2 );
    To copy to clipboard, switch view to plain text mode 

    As Wysota said, the code for "Widget2" can be implemented *anywhere*. It can even be implemented in a library (such as Qt itself) and all you need to create an instance of "Widget2" is the header file that defines the class and the library containing the compiled code.

    If you are trying to create new QWidget classes of your own and you are not ending up with new .h and .cpp files in which to implement the code for those classes, then you are not using your application development tool correctly or you have it configured wrong.
    Last edited by d_stranz; 13th March 2013 at 15:53.

  9. #9
    Join Date
    Feb 2013
    Location
    Banzart
    Posts
    54
    Thanks
    17
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to develop a multi-gui application "alternative for the stacked widget "

    Well at first i created in my project a new Qt Designer Form Class which is a widget called widget2 that created an new .ui/.cpp/.h files then i wrote this code in my mainwindow wich contain a QStackedWidget

    Qt Code:
    1. ui->stackedWidget->setCurrentIndex(0);
    2. Widget2 * newWidget2 = new Widget2;
    3. ui->stackedWidget->addWidget( newWidget2 );
    To copy to clipboard, switch view to plain text mode 
    but i doesn't do the job
    Last edited by sliverTwist; 14th March 2013 at 09:45. Reason: updated contents
    Sliver_Twist

  10. #10
    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: How to develop a multi-gui application "alternative for the stacked widget "

    In what way "it doesn't do the job"?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Feb 2013
    Location
    Banzart
    Posts
    54
    Thanks
    17
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to develop a multi-gui application "alternative for the stacked widget "

    Quote Originally Posted by wysota View Post
    In what way "it doesn't do the job"?
    Well simply i don't get that interface when i start the application i get just an empty interface which is the interface for the QStackedwidget


    Added after 5 minutes:


    this is the code of my mainWindow

    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3. #include "widget2.h"
    4. MainWindow::MainWindow(QWidget *parent) :
    5. QMainWindow(parent),
    6. ui(new Ui::MainWindow)
    7. {
    8.  
    9. ui->setupUi(this);
    10. ui->stackedWidget->setCurrentIndex(0);
    11. Widget2 *newWidget2 = new Widget2;
    12. ui->stackedWidget->addWidget(newWidget2);
    13.  
    14. }
    15.  
    16. MainWindow::~MainWindow()
    17. {
    18. delete ui;
    19.  
    20. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by sliverTwist; 14th March 2013 at 09:53.
    Sliver_Twist

  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: How to develop a multi-gui application "alternative for the stacked widget "

    I'm assuming your stack widget has two pages that are added to it by default by Designer so if you set current index to 0, you see one of those two blank pages. Either delete those two pages or set current index to 2.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #13
    Join Date
    Feb 2013
    Location
    Banzart
    Posts
    54
    Thanks
    17
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to develop a multi-gui application "alternative for the stacked widget "

    Setting the index to 2 didn't do the job neither deleting because there's no way to delete the default 2 pages created by the Designer


    Added after 5 minutes:


    I am currently working on OpenSUSE 12 64Bit and my Qt is Qt Creator 2.5.0 Based on Qt 4.8.1 (64 bit)
    Last edited by sliverTwist; 14th March 2013 at 10:11.
    Sliver_Twist

  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: How to develop a multi-gui application "alternative for the stacked widget "

    Quote Originally Posted by sliverTwist View Post
    Setting the index to 2 didn't do the job
    A riddle for you: if a book has 10 pages and you try turning to page 123 then it won't work. But if a book has 123 pages then it will work.

    neither deleting because there's no way to delete the default 2 pages created by the Designer
    I don't have any problems deleting pages created by Designer.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  15. #15
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to develop a multi-gui application "alternative for the stacked widget "

    Alternatively fill the stack with empty widgets for each page in designer and then promote each of those to the class that should be at the respective page.

    So for example if you want Widget2 to be the first page, promote the widget in page 1 to type Widget2.

    Cheers,
    _

  16. The following user says thank you to anda_skoa for this useful post:

    sliverTwist (14th March 2013)

  17. #16
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to develop a multi-gui application "alternative for the stacked widget "

    neither deleting because there's no way to delete the default 2 pages created by the Designer
    In the Object browser pane:
    • Right-click on the stacked widget
    • Select Page 1 of 2 from the context menu
    • Select Delete
    • Rinse and repeat


    Or, because TMTOWTDI, you can do it in code:
    Qt Code:
    1. QWidget *widget = ui->stackedWidget->index(0);
    2. ui->stackedWidget->removeWidget(widget);
    3. widget->deleteLater();
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 1
    Last Post: 7th April 2010, 21:46
  2. Replies: 3
    Last Post: 15th February 2010, 17:27
  3. How to develop platform independ "DLL"
    By alxwang in forum Qt Programming
    Replies: 1
    Last Post: 7th March 2009, 16:02
  4. Replies: 3
    Last Post: 8th July 2008, 19:37
  5. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05

Tags for this Thread

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.