Important: Please read the Qt Code of Conduct -

Showing and hiding pages of an application

  • I need some help with the UI of a mobile application. I'm not sure if I'm about to use the correct QML terms to describe what I want to do.

    The application has three rectangles, A, B, and C, each of which fills the phone's screen. Each rectangle has two buttons corresponding to the other two rectangles. (e.g. rectangle A has buttons B and C). I want to be able to press button B on rectangle A and have rectangle B appear in place of rectangle A.

    Maybe I can use states to determine what to display.

    I'm not sure how to hide the rectangles that aren't displayed. I considered using z-ordering until I read somewhere about a performance bug related to z-order. Of course, I cannot find that bug report now. :-(

    What I would really like is to either tap or flick a button and have the corresponding rectangle slide out from one side of the screen to cover the original rectangle.

    As always, I will be grateful for any help you folks can offer.

  • Hi there, would be best for you to check the code examples available in the SDK.
    As for this particular example I would use (for learning basically):
    Rectangle {
    id: rectangleA
    visible: true
    enabled: true

    Then in states you can address particular rectangle by ids and change their visible/enabled properties...

  • @cmer4: I appreciate your advice to check the samples in the SDK. I did that but couldn't find what I wanted. I also searched the Forum for examples. I didn't find help that way, either. I think that's because I don't know the terminology.

    Your solution works for me. Thank you.

    This morning, I stumbled on "Best way to make a game menu in Qt Quick": this morning. With what I learned there, I think I can make some nice transitions from one page to another.

  • heh David, don't worry - QML is fun, I study it for 2 months now and each day discover new great stuff;)!

Log in to reply