Results 1 to 19 of 19

Thread: Switching between two ui forms / QMainWindow screens

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #12
    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: Switching between two ui forms / QMainWindow screens

    You create the QStackedWidget, but you do not give it any parent. You do not tell your QMainWidget to use the QStackedWidget as its "centralWidget". Thus the QStackedWidget is never shown, so it is always invisible.

    Line 16 should be:

    Qt Code:
    1. stackedWidget = new QStackedWidget( this );
    To copy to clipboard, switch view to plain text mode 

    and add a line at the end of the constructor:
    Qt Code:
    1. setCentralWidget( stackedWidget );
    To copy to clipboard, switch view to plain text mode 

    If you want the background of the Raptor* widgets to be white, this code needs to be moved to their constructors. It does nothing if you have it in the Base constructor:

    Qt Code:
    1. QPalette pal = palette(); // retrieves the default palette for the widget, as defined by the app's style
    2. pal.setColor( QPalette::Window, Qt::white );
    3. setPalette( pal );
    To copy to clipboard, switch view to plain text mode 

    Edit: Actually, maybe this is incorrect. If you set the palette before creating the stacked and Raptor* widgets, it is possible that they will inherit the QPalette:: Window setting from the Base class.
    Last edited by d_stranz; 26th September 2017 at 18:05.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Switching between two forms with button click
    By gfernandes in forum Newbie
    Replies: 3
    Last Post: 30th August 2013, 12:50
  2. Multiple screens navigation
    By keyga in forum Qt Quick
    Replies: 1
    Last Post: 23rd December 2012, 10:28
  3. Problem when switching between forms in QML
    By duc_bkav in forum Qt Programming
    Replies: 0
    Last Post: 24th November 2011, 02:52
  4. Switching between 2 Forms
    By strateng in forum Qt Programming
    Replies: 6
    Last Post: 4th June 2010, 08:09
  5. Multiple Forms and vertical layout in forms
    By eva2002 in forum Qt Programming
    Replies: 0
    Last Post: 13th January 2010, 05:05

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.