QWidget initial resize event size is wrong on Android



  • When starting the program, the widget is set to Qt::WindowMaximized. Running on desktop linux, the last initial QResizeEvent is corrent (there are two, but last is correct)...
    QSize(20, 20)
    QSize(1920, 1135)

    When starting the program on Android, the last initial QResizeEvent is only 48, 48, but the widget is full screen / maximized...

    // start app on Android (should be portrait dimensions)
    D libRotate.so: ../rotate/mylayout.cpp:15 (virtual bool myLayout::eventFilter(QObject*, QEvent*)): QSize(48, 48)
    D libRotate.so: ../rotate/mylayout.cpp:15 (virtual bool myLayout::eventFilter(QObject*, QEvent*)): QSize(48, 48)
    // rotate to landscape
    D libRotate.so: ../rotate/mylayout.cpp:15 (virtual bool myLayout::eventFilter(QObject*, QEvent*)): QSize(1776, 1008)
    // rotate to portrait
    D libRotate.so: ../rotate/mylayout.cpp:15 (virtual bool myLayout::eventFilter(QObject*, QEvent*)): QSize(1080, 1704)

    Is this a bug on Android or am I not doing something right?

    main.cpp

    #include <QApplication>
    #include <QWidget>
    #include "mylayout.h"
    int main(int argc, char *argv[])
    {
    	QApplication a(argc, argv);
    
    	QWidget window;
    	myLayout layout;
    	window.setLayout(&layout);
    	window.installEventFilter(&layout);
    	window.setWindowState(Qt::WindowMaximized);
    	window.show();
    
    	return a.exec();
    }
    

    mylayout.h

    #ifndef MYLAYOUT_H
    #define MYLAYOUT_H
    #include <QBoxLayout>
    #include <QEvent>
    
    class myLayout : public QBoxLayout
    {
    	Q_OBJECT
    public:
    	myLayout();
    
    protected:
    	bool eventFilter(QObject *, QEvent *event);
    };
    
    #endif // MYLAYOUT_H
    

    mylayout.cpp

    #include "mylayout.h"
    #include <QResizeEvent>
    #include <QDebug>
    
    myLayout::myLayout() : QBoxLayout(QBoxLayout::LeftToRight)
    {
    
    }
    
    bool myLayout::eventFilter(QObject *, QEvent *event)
    {
    	event->ignore();
    	if (event->type() == QEvent::Resize) {
    		QResizeEvent *resizeEvent = static_cast<QResizeEvent *>(event);
    		qDebug() << resizeEvent->size();
    	}
    	return false;
    }
    
    

    I've tried this in 5.6 and 5.9.4



  • I also tested this code on MacOS and iOS and the initial QResizeEvents on both Qt platforms are correct. This is looking more like a bug in the Qt Android platform.


Log in to reply
 

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