Results 1 to 8 of 8

Thread: Question to state Machine and *.ui

  1. #1
    Join Date
    Mar 2014
    Posts
    18
    Thanks
    3
    Qt products
    Qt3 Qt4 Qt/Embedded

    Default Question to state Machine and *.ui

    Hi All,

    I want to realize a GUI, where the screen layout changes, when I click on a button. Like having a welcome screen with one Button and by clicking it, the screen changes to a completely different look. Therefore I implemented a state machine, that shall load the different "screens". And I made some different screens with the Designer (so I have different *.ui-Files).
    The problem is, that the Designer makes everytime a QWidget, and when the state machine starts a new screen, the old one is only closed by it. I think, I want the state machine to change only the Layout of one main QWidget.
    I found the Quiloader, but I am not sure. if that is the solution to my problem.


    Does anybody has a suggestion for me, what to do best?


    Thanks.

  2. #2
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Question to state Machine and *.ui

    QStackedWidget might be just what you need.

  3. The following user says thank you to yeye_olive for this useful post:

    nernst (13th June 2014)

  4. #3
    Join Date
    Mar 2014
    Posts
    18
    Thanks
    3
    Qt products
    Qt3 Qt4 Qt/Embedded

    Default Re: Question to state Machine and *.ui

    Hi,

    wouldn't it be better to use QStackedLayout? Then I would only have the mainWindow and would change the Layouts, when I would need a new screenView. Or is the QStackedWidget better?

  5. #4
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    506
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Question to state Machine and *.ui

    Hi, QStackedWidget is "a convenience class built on top of QStackedLayout" so they are very similar in functionality.

    Ginsengelf

  6. #5
    Join Date
    Mar 2014
    Posts
    18
    Thanks
    3
    Qt products
    Qt3 Qt4 Qt/Embedded

    Default Re: Question to state Machine and *.ui

    Hi,

    ok the hint with QStackedWidget was genious. This was exactly, what I needed.

    Thank you very much.

  7. #6
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Question to state Machine and *.ui

    Indeed, QStackedLayout works too, but I mentioned QStackedWidget because you can create and populate it directly in Qt Designer. By contrast, writing the code manually allows you to choose either solution; in that case I suppose I would use QStackedLayout because I expect it to be the (slightly) lighter alternative.

  8. #7
    Join Date
    Mar 2014
    Posts
    18
    Thanks
    3
    Qt products
    Qt3 Qt4 Qt/Embedded

    Default Re: Question to state Machine and *.ui

    Would you generally prefer creating the views with the designer or manually?

  9. #8
    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: Question to state Machine and *.ui

    I only do widgets manually if something is not possible in designer, e.g. create widgets dynamically depending on state in the application.

    For a stacked widget it would depend on how much UI related logic each page has, i.e. if a page is complex I would do it as its own widget and then add it to the stacked widget (either through promotion or in code).

    Cheers,
    _

Similar Threads

  1. state machine in its own thread
    By shaolin in forum Qt Programming
    Replies: 7
    Last Post: 4th June 2011, 13:45
  2. State Machine returning to previous state
    By akiross in forum Qt Programming
    Replies: 2
    Last Post: 10th May 2011, 00:39
  3. Replies: 0
    Last Post: 19th December 2010, 16:03
  4. State machine implementation
    By yyiu002 in forum Qt Programming
    Replies: 1
    Last Post: 28th June 2010, 04:57
  5. How to get this Qt state machine to work?
    By blukske in forum Qt Programming
    Replies: 0
    Last Post: 1st April 2010, 10:15

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.