QStackedWidget + Other widgets in a Layout displays wrong when setting to fullscreen



  • When trying to create a stacked widget layout for my system I get an error, where the stacked widget overlaps other widgets when it is enlarged to full screen.

    Below is an image of the problem i've created a border for stacked widget so that you can clearly see the problem. What happens is that stackedwidget pushes other widgets up so instead of them being above and below each other they overlap.
    !http://s12.postimg.org/799s5xmod/stackedwidget.png(Link to StackedWidget Image)!

    The Code listed below is from a function that is called by the constructor.
    @ QGridLayout * lLayout = new QGridLayout();
    QWidget * lCentralWidget = new QWidget();
    setCentralWidget(lCentralWidget);
    centralWidget()->setLayout(lLayout);

        QPalette r(palette());
        r.setColor(QPalette::Background,Qt::red);
        QPalette b(palette());
        b.setColor(QPalette::Background,Qt::black);
        QPalette g(palette());
        g.setColor(QPalette::Background,Qt::green);
    
        setWindowTitle("LXC GUI");
    
        // Create the header
        lxc::cctv::CCTVHeaderWidget * lHeader = new lxc::cctv::CCTVHeaderWidget("LXC CCTV Monitor", lCentralWidget);
        //QWidget * lHeader = new QWidget(this);
        lHeader->setMinimumHeight(20);
        lHeader->setAutoFillBackground(true);
        lHeader->setPalette(r);
        lLayout->addWidget(lHeader);
    
        // Create the menu bar widget (not the actual menubar)
        lxc::cctv::CCTVMenuBarWidget * lMenuBarWidget = new lxc::cctv::CCTVMenuBarWidget(lCentralWidget);
        //QWidget * lMenuBarWidget = new QWidget(this);
        lMenuBarWidget->setMinimumHeight(20);
        lMenuBarWidget->setAutoFillBackground(true);
        lMenuBarWidget->setPalette(g);
        lLayout->addWidget(lMenuBarWidget);
    
        QWidget *CCTV_Wrapper = new QWidget(this);
        CCTV_Wrapper->setMinimumHeight(576);
        CCTV_Wrapper->setMinimumWidth(720);
        CCTV_Wrapper->setAutoFillBackground(true);
        CCTV_Wrapper->setPalette(b);
        CCTV_Wrapper->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding);
        lLayout->addWidget(CCTV_Wrapper);
    
        lxc::cctv::CCTVFilterBarWidget * lFilterBarWidget = new lxc::cctv::CCTVFilterBarWidget(this);
        lFilterBarWidget->setMinimumHeight(20);
        lFilterBarWidget->setAutoFillBackground(true);
        lFilterBarWidget->setPalette(g);
        lLayout->addWidget(lFilterBarWidget);
    
        // Create the alarm bar
        fAlarmBarWidget = new lxc::cctv::CCTVAlarmBarWidget(this);
        //QWidget *AlarmBar = new QWidget(this);
        fAlarmBarWidget->setMinimumHeight(20);
        fAlarmBarWidget->setAutoFillBackground(true);
        fAlarmBarWidget->setPalette(g);
        lLayout->addWidget(fAlarmBarWidget);
    
        // Create form components
        createStackedWidget();
    
        createAlarmButton();
    
        QComboBox *ComboBox = new QComboBox(this);
        ComboBox->addItem(tr("Page 1"));
        ComboBox->addItem(tr("Page 2"));
        ComboBox->addItem(tr("Page 3"));
        lLayout->addWidget(ComboBox);@
    

    Create Stackedwidget function listed below.
    @void GUIForm::createStackedWidget(void)
    {
    LOG_DEBUG << "Entered";

    if (fStackedWidget == nullptr)
    {
        fStackedWidget = new QStackedWidget(this);
        fStackedWidget->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding);
        fStackedWidget->setStyleSheet("border: 1px solid red");
        
        // Add the 'idle tab'
        addIdleTab();
        // Add the 'Comms Lost tab'
        addCommsLostTab();
        
        centralWidget()->layout()->addWidget(fStackedWidget);
        
        connect(this, SIGNAL(changeSiteIdIndex(int)), 
                fStackedWidget, SLOT(setCurrentIndex(int)));
    }
    else
    {
        LOG_ERROR << "Error creating GUI Stacked Widget: One already exists. ";
    }
    

    }@


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.