Qt for android, QWidget is not in the layout, Display abnormalities
Unsolved
Mobile and Embedded
-
Qt6.7.0, I have a QWidget that is not in the layout. After executing the function QWidget:: show(), some parts of this QWidget become invisible, and after touching, some parts become visible again, or other interfaces are updated. The image is shown below, and QLabel "Content" is its Parent
-
Hi and welcome to devnet,
On which OS are you developing ?
Please provide a minimal compilable example that shows this behavior. -
@SGaist
developing OS: Windows10Dialog::Dialog(QWidget *parent) : QDialog(parent) , ui(new Ui::Dialog) { ui->setupUi(this); if(parent) { parent->installEventFilter(this); } } bool Dialog::event(QEvent *event) { if(!parent()) { return QWidget::event(event); } switch(event->type()) { case QEvent::ParentChange: { parent()->installEventFilter(this); setGeometry(overlayGeometry()); break; } case QEvent::ParentAboutToChange: { parent()->removeEventFilter(this); break; } default: break; } return QWidget::event(event); } bool Dialog::eventFilter(QObject *obj, QEvent *event) { switch(event->type()) { case QEvent::Move: case QEvent::Resize: setGeometry(overlayGeometry()); break; default: break; } return QWidget::eventFilter(obj, event); } QRect Dialog::overlayGeometry() const { QWidget *widget = parentWidget(); if(!widget) { return QRect(); } return widget->rect(); }
And
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); m_form = new Dialog; m_form->hide(); m_form->setParent(ui->widget_2); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_pushButton_clicked() { m_form->show(); } void MainWindow::on_pushButton_2_clicked() { m_form->hide(); }
As shown in the figure, "widget_1" is on the left and "widget_2" is on the right, "dialog.ui" is all filled with pink