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. MessageDialog on iOS

MessageDialog on iOS

Scheduled Pinned Locked Moved Mobile and Embedded
11 Posts 6 Posters 5.8k Views
  • 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.
  • J Offline
    J Offline
    jimcad
    wrote on last edited by
    #1

    I'd like show messagebox on iOS app. But unfortunately there is no native look dialogs for iOS. I could use MessageDialogs but they look bad and are in full screen size (tested on Qt 5.3.1). Is there existing native dialogs (or coming) or should I use custom dialogs? If so, what is the best way to do it?

    1 Reply Last reply
    0
    • GianlucaG Offline
      GianlucaG Offline
      Gianluca
      wrote on last edited by
      #2

      On iOS you can mix very easily object-C with C++ code, and then, you can easily create a QObject subclass with a slot implemented in object-c on which you can create a iOS native message dialog and emit a signal on the delegate methods of native message dialogs.
      I used this technique for showing UIAlertViews. I didn't try with UIActionSheet and UIActivityIndicator, but it should be easy.

      Otherwise, in another app, I created a custom dialogs. For doing so, I just created a full screen QML item with a semi-transparent gray rectangle filling the screen with a MouseArea catching any touches (in this way the dialogs behaves as a modal dialog) and adding to the center an item with the necessary graphics items for display the message and the buttons as the designer created them.
      You can decide if to create this item on-fly every time with Qt.createComponent when you need, or you can create a single global instance to setup and make visible every time you need.

      R 1 Reply Last reply
      0
      • J Offline
        J Offline
        jimcad
        wrote on last edited by
        #3

        @Gianluca Thank you very much. I never used Objective-C before but I tested and now I have a working simple messagebox (done with UIActionView). Indeed it seems to be quite easy mix Objective-C and C++. Thanks for this tip.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          Tycos
          wrote on last edited by
          #4

          [quote author="Gianluca" date="1404026975"]On iOS you can mix very easily object-C with C++ code, and then, you can easily create a QObject subclass with a slot implemented in object-c on which you can create a iOS native message dialog and emit a signal on the delegate methods of native message dialogs.
          I used this technique for showing UIAlertViews. I didn't try with UIActionSheet and UIActivityIndicator, but it should be easy.

          Otherwise, in another app, I created a custom dialogs. For doing so, I just created a full screen QML item with a semi-transparent gray rectangle filling the screen with a MouseArea catching any touches (in this way the dialogs behaves as a modal dialog) and adding to the center an item with the necessary graphics items for display the message and the buttons as the designer created them.
          You can decide if to create this item on-fly every time with Qt.createComponent when you need, or you can create a single global instance to setup and make visible every time you need.
          [/quote]

          Hi Gianluca,

          about your second solution (I want re-use the code also for Android), it was no more simple use the component "Dialog" for make a custom dialog in modality mode? Where is the convenience to make a custom rectangle ?

          1 Reply Last reply
          0
          • benlauB Offline
            benlauB Offline
            benlau
            Qt Champions 2016
            wrote on last edited by
            #5

            There has an example implementation of alert dialog for Android:

            https://github.com/benlau/quickandroid/blob/master/tests/quickandroidexample/dialog/AlertDialog.qml

            However, I think it is not a suggested method for iOS. Since the background mask of an iOS dialog will cover status bar . QML can not handle it. As it will not fulfill the requirement of app store , just afraid it will be banned.

            1 Reply Last reply
            0
            • GianlucaG Offline
              GianlucaG Offline
              Gianluca
              wrote on last edited by
              #6

              [quote author="Tycos" date="1414748285"][quote author="Gianluca" date="1404026975"]On iOS you can mix very easily object-C with C++ code, and then, you can easily create a QObject subclass with a slot implemented in object-c on which you can create a iOS native message dialog and emit a signal on the delegate methods of native message dialogs.
              I used this technique for showing UIAlertViews. I didn't try with UIActionSheet and UIActivityIndicator, but it should be easy.

              Otherwise, in another app, I created a custom dialogs. For doing so, I just created a full screen QML item with a semi-transparent gray rectangle filling the screen with a MouseArea catching any touches (in this way the dialogs behaves as a modal dialog) and adding to the center an item with the necessary graphics items for display the message and the buttons as the designer created them.
              You can decide if to create this item on-fly every time with Qt.createComponent when you need, or you can create a single global instance to setup and make visible every time you need.
              [/quote]

              Hi Gianluca,

              about your second solution (I want re-use the code also for Android), it was no more simple use the component "Dialog" for make a custom dialog in modality mode? Where is the convenience to make a custom rectangle ?[/quote]

              The convenience of make a custom rectangle depends on how much is the graphics of the dialog created by the designer. In the app I was referring on the reply, the designed created a very complex design of the dialog and for me was more easy to do with custom Items, instead of using the QtQuick Controls and customize the appearance via QtQuickControls.Styles.

              1 Reply Last reply
              0
              • GianlucaG Gianluca

                On iOS you can mix very easily object-C with C++ code, and then, you can easily create a QObject subclass with a slot implemented in object-c on which you can create a iOS native message dialog and emit a signal on the delegate methods of native message dialogs.
                I used this technique for showing UIAlertViews. I didn't try with UIActionSheet and UIActivityIndicator, but it should be easy.

                Otherwise, in another app, I created a custom dialogs. For doing so, I just created a full screen QML item with a semi-transparent gray rectangle filling the screen with a MouseArea catching any touches (in this way the dialogs behaves as a modal dialog) and adding to the center an item with the necessary graphics items for display the message and the buttons as the designer created them.
                You can decide if to create this item on-fly every time with Qt.createComponent when you need, or you can create a single global instance to setup and make visible every time you need.

                R Offline
                R Offline
                rushmore
                wrote on last edited by
                #7

                @Gianluca Would it be possible to show how you did it? I'm not quite familiar with objective c so a sample code would be very helpful. Thank you!

                benlauB 1 Reply Last reply
                0
                • R rushmore

                  @Gianluca Would it be possible to show how you did it? I'm not quite familiar with objective c so a sample code would be very helpful. Thank you!

                  benlauB Offline
                  benlauB Offline
                  benlau
                  Qt Champions 2016
                  wrote on last edited by
                  #8

                  @rushmore An example implementation:

                  https://github.com/benlau/quickios/blob/master/qialertview.h
                  https://github.com/benlau/quickios/blob/master/qisystemutils.mm#L77

                  R M 2 Replies Last reply
                  1
                  • benlauB benlau

                    @rushmore An example implementation:

                    https://github.com/benlau/quickios/blob/master/qialertview.h
                    https://github.com/benlau/quickios/blob/master/qisystemutils.mm#L77

                    R Offline
                    R Offline
                    rushmore
                    wrote on last edited by
                    #9

                    @benlau Thank you!

                    1 Reply Last reply
                    0
                    • benlauB benlau

                      @rushmore An example implementation:

                      https://github.com/benlau/quickios/blob/master/qialertview.h
                      https://github.com/benlau/quickios/blob/master/qisystemutils.mm#L77

                      M Offline
                      M Offline
                      m_andrej
                      wrote on last edited by
                      #10

                      @benlau Let me notify you of a possible error in qisystemmessenger.h. It contains this inclusion guard:

                      #ifndef QISYSTEMUTILS_H
                      #define QISYSTEMUTILS_H
                      

                      Which seems like a copy-paste error. BTW isn't it best to use #pragma once?
                      But thanks for your work.

                      benlauB 1 Reply Last reply
                      0
                      • M m_andrej

                        @benlau Let me notify you of a possible error in qisystemmessenger.h. It contains this inclusion guard:

                        #ifndef QISYSTEMUTILS_H
                        #define QISYSTEMUTILS_H
                        

                        Which seems like a copy-paste error. BTW isn't it best to use #pragma once?
                        But thanks for your work.

                        benlauB Offline
                        benlauB Offline
                        benlau
                        Qt Champions 2016
                        wrote on last edited by benlau
                        #11

                        @m_andrej Thanks for pointing out the problem. In fact, the mistake is not made by C&P. That is the original name of QISystemMessenger. Since the class is growthing, I have refactored the code to breakdown into multiple classes. But forgotten to rename the include guild.

                        "#pragma once" should be fine, I just use the default header file generator from Qt Creator.

                        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