我有一个主小部件和多个子小部件要显示。
我将所有子小部件添加到主小部件布局中,并只显示一个孩子并隐藏其他孩子。
在 Windows PC 中,这可以正常工作。但是在 android 中,即使调用了 hide,子小部件也会出现。任何人都可以建议我错在哪里。
#include "mainframe.h"
#include "ui_mainframe.h"
MainFrame::MainFrame(QWidget *parent) :
QWidget(parent),
ui(new Ui::MainFrame)
{
ui->setupUi(this);
m_pMainLayout = ui->gridLayout;
initialize();
}
MainFrame::~MainFrame()
{
delete ui;
}
void MainFrame::initialize()
{
m_pStartupScreen = new StartupScreen(this);
m_pSystemScreen = new SystemScreen(this);
m_pMainLayout->addWidget(m_pStartupScreen);
m_pMainLayout->addWidget(m_pSystemScreen);
connect(m_pStartupScreen, SIGNAL(reportsButtonClick()),
this, SLOT(handleUserOptionReports()));
connect(m_pStartupScreen, SIGNAL(systemButtonClick()),
this, SLOT(handleUserOptionSystem()));
connect(m_pStartupScreen, SIGNAL(salesButtonClick()),
this, SLOT(handleUserOptionSales()));
m_pSystemScreen->hide();
m_pStartupScreen->show();
connect(m_pSystemScreen, SIGNAL(closeInvoked()), m_pStartupScreen, SLOT(show()));
}
m_pStartupScreen
并m_pSystemScreen
出现在 android 设备中,即两个子小部件出现重叠。