Results 1 to 5 of 5

Thread: MessageDialog does not work on iOS

  1. #1
    Join Date
    May 2009
    Location
    Canada
    Posts
    163
    Thanks
    7
    Thanked 20 Times in 20 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows Android

    Default MessageDialog does not work on iOS

    I have a silly little custom MessageDialog that is intended to solicit confirmation from a user before deleting DLC. Here is the code:

    Qt Code:
    1. import QtQuick 2.5
    2. import QtQuick.Dialogs 1.2
    3.  
    4. MessageDialog {
    5. id: root
    6.  
    7. property string dlcName: ""
    8.  
    9. icon: StandardIcon.Information
    10. title: qsTr("Delete content")
    11. text: qsTr("<p>You are about to delete '" + dlcName + "'. " +
    12. "If you wish to access this content in future, you will have to re-download it.</p>" +
    13. "<p>Tap 'OK' when you are ready to proceed.</p>")
    14. standardButtons: StandardButton.Cancel | StandardButton.Ok
    15. }
    To copy to clipboard, switch view to plain text mode 

    And here is the calling code:

    Qt Code:
    1. Item {
    2. id: root
    3.  
    4. signal deletionRequested(string dlcName)
    5.  
    6. function alertDeletion(name) {
    7. deleteDialog.dlcName = name
    8. deleteDialog.open()
    9. }
    10.  
    11. anchors.fill: parent
    12.  
    13. DeleteDLCDialog {
    14. id: deleteDialog
    15.  
    16. onAccepted: root.deletionRequested(dlcName)
    17. }
    18.  
    19. ....
    20. }
    To copy to clipboard, switch view to plain text mode 

    This works great on Desktop (i.e., MacOSX) and Android, but no dialog appears on iOS. Console logging shows that the alertDeletion function is called. If I change MessageDialog to FileDialog (and comment out the now-invalid properties, of course) then I see a file dialog as expected.

    I found a bug about this here. But it's somewhat old, the "workaround" posted in the comments doesn't work for me, and I can't find anything else. I've tried running in debug and release mode, with no difference. Is this still an issue in others' experience? Is it solvable, and if so, how? If not, what is the recommended workaround?

    I'm running Qt Creator 4.1.0, based on Qt 5.7.0 (Clang 7.0 (Apple), 64 bit).

    Thank you very much!

  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: MessageDialog does not work on iOS

    The bug report might not be applicable, I think the problem there was showing the message dialog "too soon", i.e. while the application was not fully ready yet.
    My guess is your dialog is triggered via user interaction.

    Have you tried a very minimal example, just some UI for the user to trigger the message dialog?

    Cheers,
    _

    P.S.: don't concatenate runtime data into a translated string, positioning will depend on the translation. Use the arg() mechansim instead

  3. #3
    Join Date
    May 2009
    Location
    Canada
    Posts
    163
    Thanks
    7
    Thanked 20 Times in 20 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows Android

    Default Re: MessageDialog does not work on iOS

    Have you tried a very minimal example, just some UI for the user to trigger the message dialog?
    In fact, my "application" at this point is all UI, and quite minimal: a Page containing a dummy ListModel gets pushed onto a StackView; each delegate has a "Delete" Button whose onClicked handler calls the alertDeletion() function shown. There is as yet not a single line of C++ code beyond the boilerplate in main.cpp.

    Thanks for the tip re: qsTr().

    Since posting I've tried running on a different physical device but the result was the same. I'm going to confirm that there isn't something silly happening with the MessageDialog such as a width or height of zero. Once the sanity checks are concluded, I will try exposing a subclass of QMessageBox to QML, per the supposed fallback mechanism in the documentation.

    Any further insight is appreciated.

  4. #4
    Join Date
    May 2009
    Location
    Canada
    Posts
    163
    Thanks
    7
    Thanked 20 Times in 20 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows Android

    Default Re: MessageDialog does not work on iOS

    Findings re: width and height as shown by console.debug() statements in my custom MessageDialog:

    Qt Code:
    1. qml: Component.onCompleted() - visible:false
    2. /* button press event */
    3. qml: DeleteDLCDialog::onVisibleChanged() - visible:true
    4. qml: height:0
    5. qml: width:0
    To copy to clipboard, switch view to plain text mode 

    What's even more disturbing is that if I explicitly set the width and height, the correct values are printed but there is still no dialog in evidence!

  5. #5
    Join Date
    May 2009
    Location
    Canada
    Posts
    163
    Thanks
    7
    Thanked 20 Times in 20 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows Android

    Default Re: MessageDialog does not work on iOS

    It turns out that this is partially a result of how the iOS plugin works, and partially a bug related to the supposed fallback mechanism. See the bug report here (fixed for 5.7.1). Setting the modality to Qt.ApplicationModal does the trick.

  6. The following user says thank you to Urthas for this useful post:

    anda_skoa (13th December 2016)

Similar Threads

  1. Replies: 0
    Last Post: 10th April 2015, 14:05
  2. Replies: 3
    Last Post: 9th October 2012, 02:12
  3. Replies: 0
    Last Post: 12th July 2011, 08:20
  4. Replies: 2
    Last Post: 13th December 2009, 20:27
  5. Replies: 3
    Last Post: 15th January 2008, 12:11

Tags for this Thread

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.