Important: Please read the Qt Code of Conduct -

GUI program structure

  • Hi,

    I'm working on a project where there is 2 different step.
    1.The user select an item in a list.
    2. By clicking on "details" button, the user access to the selected item details.

    But i don't know how to structure my code.
    Do i need to create to different frame in the mainwindow ? And how do i switch between these 2 frame ?


  • Lifetime Qt Champion

    Hi and welcome
    Why do you want frames?
    What will display the details?
    Some QLabels or ??

    Will you use Models and Views or
    something more simple?

    How is the data stored?
    you have some struct with data ?

  • Hi,

    I think i'm not using appropriate words (not very good in english).

    I want one "home page" with a list and a "details" button.
    Once the user selected and item and clicked on the button, the page change to display item details (mostly labels).
    I don't want to open a new window.

    I heard that a stackedWidget could be a solution.

  • Lifetime Qt Champion

    Yes, qstackedwidget is good for concept of pages/screens.

    But nothing stop you from having a List and say a QTableWidget
    and when u click in list, the Tablewidget shows the Details.
    This is all in same window.
    If nothing selected in List, Table is empty,. (start situation)

    Oh. Update:
    WHen he clicks Button, the list should not be available anymore?

  • I think QStackedWidget is the more appropriate solution for me.

    On the "details" page, the user have a "back" button to go back to the "home" page.
    The list is filled with a SQL query and have to be refreshed every time the user go back to the "home" page or every minutes to avoid missing new items in the DB.

  • Lifetime Qt Champion

    I agree.
    If the wanted design is sort of Like wizard with Next and back
    then QStackedWIdget is perfect and easy to use.

  • Thank you very much.

Log in to reply