Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt for android, QWidget is not in the layout, Display abnormalities
Forum Updated to NodeBB v4.3 + New Features

Qt for android, QWidget is not in the layout, Display abnormalities

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
3 Posts 2 Posters 318 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NeosYang
    wrote on last edited by
    #1

    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

    1720261773239.jpg
    ae8ef66c1ae9155d148ee8acfcbe1308.png
    12cb14efd57d54c519fd6fc1fa783a64.png

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      On which OS are you developing ?
      Please provide a minimal compilable example that shows this behavior.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      N 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        On which OS are you developing ?
        Please provide a minimal compilable example that shows this behavior.

        N Offline
        N Offline
        NeosYang
        wrote on last edited by NeosYang
        #3

        @SGaist
        developing OS: Windows10

        Dialog::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
        f3fa9438a9f26e7747283f26da4490fd.png

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved