Results 1 to 5 of 5

Thread: Android: QDialog becomes invisible when adding QML component (QQuickWidget) to it

  1. #1
    Join Date
    Jul 2006
    Posts
    20
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Android: QDialog becomes invisible when adding QML component (QQuickWidget) to it

    In a Widgets application I want to show a modal dialog designed with QML.

    I chose to create a QDialog and insert the QML component inside it. This works well on desktop, but leads to an invisible window on Android. When showing the QDialog with a QPushButton it works as expected, but when I add a QQuickWidget to it, the QDialog becomes invisible.

    The mouse area _does_ react to clicks and when I print the sizes at various steps they seem fine. Also, when rotating the device or bringing the app to front, I get to see a glimpse of the QDialog window and it seems to look as expected.


    C++ file:
    Qt Code:
    1. AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent) {
    2. if (layout() != NULL)
    3. delete layout();
    4. QGridLayout* gridLayout= new QGridLayout();
    5. setLayout(gridLayout);
    6.  
    7. okButton = new QPushButton("Close", this);
    8. gridLayout->addWidget(okButton, 1, 0);
    9.  
    10. quickWidget = new QQuickWidget();
    11. quickWidget->setSource(QUrl("qrc:/Example.qml"));
    12. quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
    13. quickWidget->resize(100, 100);
    14.  
    15. gridLayout->addWidget(quickWidget, 0, 0);
    16.  
    17. resize(800, 800);
    18. }
    To copy to clipboard, switch view to plain text mode 

    Header file:
    Qt Code:
    1. class AboutDialog : public QDialog {
    2. public:
    3. AboutDialog(QWidget* parent=0);
    4.  
    5. private:
    6. QQuickWidget* quickWidget = NULL;
    7. QPushButton* okButton;
    8. };
    To copy to clipboard, switch view to plain text mode 

    QML file:
    Qt Code:
    1. import QtQuick 2.0
    2.  
    3. Rectangle {
    4. width: 700
    5. height: 700
    6.  
    7. color: "#000000"
    8.  
    9. Rectangle {
    10. height: 600
    11. anchors.left: parent.left; anchors.right: parent.right
    12. anchors.leftMargin: 30; anchors.rightMargin: 30
    13. anchors.bottom: parent.bottom
    14. anchors.bottomMargin: 30
    15. color: "#dd0000"
    16.  
    17. Text {
    18. anchors.centerIn: parent
    19. font.pixelSize: 30
    20. text: "Quit"
    21. color: "#e0e0e0"
    22. }
    23.  
    24. MouseArea {
    25. anchors.fill: parent
    26. onClicked: Qt.quit();
    27. }
    28. }
    29. }
    To copy to clipboard, switch view to plain text mode 

    Added after 14 minutes:


    Adb logcat of what seemed relevant (happens on all 3 device I tried with):
    Qt Code:
    1. #Trigger showing the window, FreeGo is the name of the App.
    2.  
    3. D/FreeGo ( 8885): void GameSettings::showMenu()
    4. W/libFreeGo.so( 8885): (null):0 ((null)): This plugin does not support grabbing the keyboard
    5. E/Parcel ( 440): Reading a NULL string not supported here.
    6. E/Parcel ( 440): Reading a NULL string not supported here.
    7. W/qdhwcomposer( 318): Excessive delay reading vsync: took 500 ms
    8. W/qdhwcomposer( 318): Excessive delay reading vsync: took 216 ms
    9. D/FreeGo ( 8885): AboutDialog::AboutDialog(QWidget*)
    10. D/FreeGo ( 8885): AboutDialog::AboutDialog(QWidget*) - sizes: window: (0 0) 800x800;
    11. D/FreeGo ( 8885): quickWidget:(0 0) 100x100
    12. D/FreeGo ( 8885): virtual int AboutDialog::exec() - sizes: window: (0 0) 800x800;
    13. D/FreeGo ( 8885): quickWidget:(0 0) 100x100
    14. D/FreeGo ( 8885): virtual void AboutDialog::resizeEvent(QResizeEvent*) - sizes: window: (487 62) 800x800;
    15. D/FreeGo ( 8885): quickWidget:(24 24) 752x595
    16. D/FreeGo ( 8885): virtual void AboutDialog::resizeEvent(QResizeEvent*) - sizes: window: (487 62) 800x800;
    17. D/FreeGo ( 8885): quickWidget:(24 24) 752x595
    18. W/Adreno-EGL( 8885): <qeglDrvAPI_eglSwapInterval:3818>: EGL_BAD_SURFACE
    19. W/Adreno-EGL( 8885): <qeglDrvAPI_eglSwapInterval:3818>: EGL_BAD_SURFACE
    20. W/qdhwcomposer( 318): Excessive delay reading vsync: took 83 ms
    21. W/WindowManager( 854): Access to extended visibility flags denied: Requires com.sonymobile.permission.SYSTEM_UI_VISIBILITY_EXTENSIONS permission.
    22. W/WindowManager( 854): Access to extended visibility flags denied: Requires com.sonymobile.permission.SYSTEM_UI_VISIBILITY_EXTENSIONS permission.
    23. W/WindowManager( 854): Access to extended visibility flags denied: Requires com.sonymobile.permission.SYSTEM_UI_VISIBILITY_EXTENSIONS permission.
    24. W/WindowManager( 854): Access to extended visibility flags denied: Requires com.sonymobile.permission.SYSTEM_UI_VISIBILITY_EXTENSIONS permission.
    25. W/qdhwcomposer( 318): Excessive delay reading vsync: took 300 ms
    26. W/qdhwcomposer( 318): Excessive delay reading vsync: took 1401 ms
    27.  
    28.  
    29. #Press the back button here:
    30.  
    31. D/FreeGo ( 8885): virtual int AboutDialog::exec() - sizes: window: (487 62) 800x800;
    32. D/FreeGo ( 8885): quickWidget:(24 24) 752x595
    33. D/FreeGo ( 8885): virtual int AboutDialog::exec() - retVal=0
    34. D/FreeGo ( 8885): virtual AboutDialog::~AboutDialog() - sizes: window: (487 62) 800x800;
    35. D/FreeGo ( 8885): quickWidget:(24 24) 752x595
    36. W/WindowManager( 854): Access to extended visibility flags denied: Requires com.sonymobile.permission.SYSTEM_UI_VISIBILITY_EXTENSIONS permission.
    37. W/qdhwcomposer( 318): Excessive delay reading vsync: took 38 ms
    38. W/WindowManager( 854): Access to extended visibility flags denied: Requires com.sonymobile.permission.SYSTEM_UI_VISIBILITY_EXTENSIONS permission.
    39. W/libFreeGo.so( 8885): (null):0 ((null)): Can't find surface 4
    40. W/WindowManager( 854): Access to extended visibility flags denied: Requires com.sonymobile.permission.SYSTEM_UI_VISIBILITY_EXTENSIONS permission.
    41. E/Parcel ( 440): Reading a NULL string not supported here.
    To copy to clipboard, switch view to plain text mode 
    Last edited by alecs1; 8th March 2015 at 12:26.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Android: QDialog becomes invisible when adding QML component (QQuickWidget) to it

    You could try a QQuickWindow instead of the QDialog.

    A simple subclass with an exec() like method that sets the modality of the window, shows it and executes a nested event loop.

    Cheers,
    _

  3. #3
    Join Date
    Jul 2006
    Posts
    20
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Android: QDialog becomes invisible when adding QML component (QQuickWidget) to it

    Same behaviour with QQuickView. I tried it like this:

    Qt Code:
    1. QQuickView* view = new QQuickView();
    2. view->setSource(QUrl("qrc:/Example.qml"));
    3. view->show();
    To copy to clipboard, switch view to plain text mode 

    However, I noticed on the older phone that if I press home and then bring the program back to front with the task manager, then the QDialog/QQuickView will actually display and stay there for good. On the newer phone it only show for a fraction of a second.

    Apart from the code, are there other important parts I may be missing? Like AndroidManifest.xml or project flags? If of any use, I could upload short movie somewhere. and the entire code is online at https://github.com/alecs1/home/tree/master/qt/qtgo/qtgo.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Android: QDialog becomes invisible when adding QML component (QQuickWidget) to it

    Sorry, no further idea.
    It could be a limiation of the Android integration, i.e. the mixing of OpenGL and non-OpenGL rendering.

    Cheers,
    _

  5. #5
    Join Date
    Jul 2006
    Posts
    20
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Android: QDialog becomes invisible when adding QML component (QQuickWidget) to it

    Thanks, I'll reach for Digia with this question and 1-2 widgets bugs on Android.

Similar Threads

  1. QQuickView or QQmlApplicationEngine or QQuickWidget
    By ustulation in forum Qt Quick
    Replies: 0
    Last Post: 18th January 2015, 14:16
  2. Replies: 2
    Last Post: 21st August 2014, 20:36
  3. Replies: 1
    Last Post: 12th April 2014, 11:55
  4. Replies: 5
    Last Post: 19th April 2010, 00:31
  5. adding QAction to QDialog is not working
    By sanjayshelke in forum Qt Programming
    Replies: 3
    Last Post: 13th August 2008, 10:39

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.