Results 1 to 8 of 8

Thread: Navigation between windows

  1. #1

    Default Navigation between windows

    Hi to everyone,

    I come from Java and I'm doing my first steps into QT. I'm using the designer to develop an app that has multiple windows and I have to navigate between them. To clarify a bit more this, I'm developing a kind of Car Infotainment System, where I have some buttons on the left, and each of these buttones sends me to different windows (media, radio, GPS, etc...)

    My problem is that I don't know how to navigate between theses windows. After reading a lot, I've find that QStackedWidget could do the job, but this works using indexes and navigating left-right through the widgets. What I need is that each button I press sends me to a determided window.

    In android, I would create a frameContainer ant the right side and then programmatically change the layout each time I press a button, but I'm very lost here, I don't find complete examples of how to do this.

    So I'm not asking you a complete tutorial of how to doing this, just give me some steps of what to use and how to use it to be able to continue.

    Thanks.

  2. #2
    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: Navigation between windows

    Quote Originally Posted by masmic View Post
    I come from Java and I'm doing my first steps into QT. I'm using the designer to develop an app that has multiple windows and I have to navigate between them. To clarify a bit more this, I'm developing a kind of Car Infotainment System, where I have some buttons on the left, and each of these buttones sends me to different windows (media, radio, GPS, etc...)
    That sounds more like you have a single window with the content changing depending on state.

    Quote Originally Posted by masmic View Post
    What I need is that each button I press sends me to a determided window.
    That is exactly what QStackedWidget does: you tell it which of its page it should show and it shows that one.

    You can either set the widget to show in a slots connected to the buttons or use a QSignalMapper to map from button to which widgets to show.

    Cheers,
    _

    P.S.: for touch based embedded devices the technology of choice is often QtQuick instead of QtWidgets, as it makes "phone like" experience easier to achieve

  3. #3

    Default Re: Navigation between windows

    So QStackedWidget could do the job? I thought that I could only change pages with the left-right arrows. Is there any tutorial or example of this behaviour?

  4. #4
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,540
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Navigation between windows

    Look at "Config Dialog Example" in Qt examples.

  5. #5

    Default Re: Navigation between windows

    Thanks! But could I do this using the designer? Os theses things must be done coding?

  6. #6
    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: Navigation between windows

    Quote Originally Posted by masmic View Post
    So QStackedWidget could do the job? I thought that I could only change pages with the left-right arrows.
    Where does QStackedWidget::setCurrentIndex() or QStackedWidget::setCurrentWidget() say anything about left-right arrows?

    Cheers,
    _

  7. #7

    Default Re: Navigation between windows

    Quote Originally Posted by anda_skoa View Post
    Where does QStackedWidget::setCurrentIndex() or QStackedWidget::setCurrentWidget() say anything about left-right arrows?

    Cheers,
    _
    I just tell that because when adding it in the designer it shows by default thos arrows

  8. #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: Navigation between windows

    Quote Originally Posted by masmic View Post
    I just tell that because when adding it in the designer it shows by default thos arrows
    Yes, so that you can conveniently switch between pages in designer.

    The stacked widget does not have any UI of its own, it just shows its pages.
    You can easily see this if you preview the form.

    In a real application one most often does not add pages in designer but design each page and then put instances of them into the stack in code.

    Cheers,
    _

Similar Threads

  1. Control Tab Navigation
    By sterling in forum Qt Programming
    Replies: 1
    Last Post: 20th August 2014, 08:38
  2. QML screen navigation how to
    By anish in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 27th October 2013, 21:08
  3. page navigation
    By ningoji in forum Newbie
    Replies: 2
    Last Post: 5th April 2011, 11:15
  4. Navigation purpose
    By jerkymotion in forum Qt Programming
    Replies: 6
    Last Post: 17th March 2011, 17:59
  5. Tab navigation and QListWidget
    By Arthur in forum Qt Programming
    Replies: 5
    Last Post: 9th March 2007, 19:07

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
  •  
Qt is a trademark of The Qt Company.