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. Geometry wrong on iOS device
Qt 6.11 is out! See what's new in the release blog

Geometry wrong on iOS device

Scheduled Pinned Locked Moved Solved Mobile and Embedded
22 Posts 4 Posters 8.9k Views 2 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.
  • K KoneTaH

    Can you provide a code fragment please? How exactly you show this QQuickView on the screen? Did you try to call showFullScreen() for it instead of just show() for example?

    int main(int argc, char *argv[])
    {
        QGuiApplication app(argc, argv);
    
        QQuickView *view = new QQuickView;
        view->setSource(...);
        view->showFullScreen();
      
        return app.exec();
    }
    
    K Offline
    K Offline
    KoneTaH
    wrote on last edited by
    #3
    This post is deleted!
    1 Reply Last reply
    0
    • _eph_ Offline
      _eph_ Offline
      _eph
      wrote on last edited by _eph
      #4

      Yes, so if I just create simple qml - using your example:

      #import <QQuickView>
      #include <QtPlugin>
      Q_IMPORT_PLUGIN(QtQuick2Plugin)
      #endif
      
      int main(int argc, char *argv[])
      {
          QGuiApplication app(argc, argv);
          
          QQuickView *view = new QQuickView;
          view->setSource(QUrl::fromLocalFile("/tmp/simple.qml"));
          view->showFullScreen();
          
          return app.exec();
      }
      

      and the QML:

      import QtQuick 2.0
      
      Rectangle {
          id: page
          width: 300; height: 200
          color: "yellow"
      
          Text {
              id: helloText
              text: "Hello world!"
              y: 30
              anchors.horizontalCenter: page.horizontalCenter
              font.pointSize: 24; font.bold: true
          }
      }
      

      This is the result:
      0_1552871529629_Simulator Screen Shot - iPhone XR - 2019-03-18 at 13.06.58.png

      K J.HilkJ 2 Replies Last reply
      0
      • _eph_ _eph

        Yes, so if I just create simple qml - using your example:

        #import <QQuickView>
        #include <QtPlugin>
        Q_IMPORT_PLUGIN(QtQuick2Plugin)
        #endif
        
        int main(int argc, char *argv[])
        {
            QGuiApplication app(argc, argv);
            
            QQuickView *view = new QQuickView;
            view->setSource(QUrl::fromLocalFile("/tmp/simple.qml"));
            view->showFullScreen();
            
            return app.exec();
        }
        

        and the QML:

        import QtQuick 2.0
        
        Rectangle {
            id: page
            width: 300; height: 200
            color: "yellow"
        
            Text {
                id: helloText
                text: "Hello world!"
                y: 30
                anchors.horizontalCenter: page.horizontalCenter
                font.pointSize: 24; font.bold: true
            }
        }
        

        This is the result:
        0_1552871529629_Simulator Screen Shot - iPhone XR - 2019-03-18 at 13.06.58.png

        K Offline
        K Offline
        KoneTaH
        wrote on last edited by
        #5

        @_eph Try to call viewer->setResizeMode(QQuickView::SizeRootObjectToView) before calling showFullScreen().

        1 Reply Last reply
        0
        • _eph_ Offline
          _eph_ Offline
          _eph
          wrote on last edited by _eph
          #6

          @KoneTaH said in Geometry wrong on iOS device:

          viewer->setResizeMode(QQuickView::SizeRootObjectToView)

          The yellow now fills the whole white box and the text is centered but it's still contained to the same window as before.

          K 1 Reply Last reply
          0
          • _eph_ _eph

            @KoneTaH said in Geometry wrong on iOS device:

            viewer->setResizeMode(QQuickView::SizeRootObjectToView)

            The yellow now fills the whole white box and the text is centered but it's still contained to the same window as before.

            K Offline
            K Offline
            KoneTaH
            wrote on last edited by KoneTaH
            #7

            @_eph This one works for me:

            main.cpp:

            #include <QGuiApplication>
            #include <QQuickView>
            
            int main(int argc, char *argv[])
            {
                QGuiApplication app(argc, argv);
            
                QQuickView *view = new QQuickView(QUrl(QStringLiteral("qrc:/main.qml")));
            
                view->showFullScreen();
            
                return app.exec();
            }
            

            main.qml:

            import QtQuick 2.0
            
            Rectangle {
                anchors.fill: parent
                color: "red"
            
                Rectangle {
                    width: 100
                    height: 100
                    color: "yellow"
                    anchors.centerIn: parent
                }
            }
            

            Qt 5.12.1.

            1 Reply Last reply
            0
            • _eph_ Offline
              _eph_ Offline
              _eph
              wrote on last edited by
              #8

              Are you using qmake/qtcreator?

              Looks the same for me:
              0_1552871341318_Simulator Screen Shot - iPhone XR - 2019-03-18 at 14.07.03.png

              K 1 Reply Last reply
              0
              • _eph_ _eph

                Are you using qmake/qtcreator?

                Looks the same for me:
                0_1552871341318_Simulator Screen Shot - iPhone XR - 2019-03-18 at 14.07.03.png

                K Offline
                K Offline
                KoneTaH
                wrote on last edited by KoneTaH
                #9

                @_eph Yes, it's a qmake project ("Qt Quick Application - Empty" template with changes in main.cpp and main.qml), I build it using both Qt Creator and XCode, and see no difference - it work as expected.

                1 Reply Last reply
                0
                • _eph_ Offline
                  _eph_ Offline
                  _eph
                  wrote on last edited by
                  #10

                  Yeah, there must be something qmake does which makes the difference...

                  K 1 Reply Last reply
                  0
                  • _eph_ _eph

                    Yeah, there must be something qmake does which makes the difference...

                    K Offline
                    K Offline
                    KoneTaH
                    wrote on last edited by
                    #11

                    @_eph Here is an example of Qt cmake QML project for iOS with QQuickView:

                    https://github.com/forexample/qt-ios-examples/tree/master/qml-custom-property-types

                    In main.cpp it imports some plugin called "QIOSIntegrationPlugin". May be you should import it too?

                    _eph_ 1 Reply Last reply
                    0
                    • K KoneTaH

                      @_eph Here is an example of Qt cmake QML project for iOS with QQuickView:

                      https://github.com/forexample/qt-ios-examples/tree/master/qml-custom-property-types

                      In main.cpp it imports some plugin called "QIOSIntegrationPlugin". May be you should import it too?

                      _eph_ Offline
                      _eph_ Offline
                      _eph
                      wrote on last edited by
                      #12

                      @KoneTaH Tried but no difference :(

                      K 1 Reply Last reply
                      0
                      • _eph_ _eph

                        @KoneTaH Tried but no difference :(

                        K Offline
                        K Offline
                        KoneTaH
                        wrote on last edited by KoneTaH
                        #13

                        @_eph Please note that main() in iOS case is called qtmn(). It's not the real main() and it will be called from this plugin after some initial setup (as I think).

                        _eph_ 1 Reply Last reply
                        0
                        • K KoneTaH

                          @_eph Please note that main() in iOS case is called qtmn(). It's not the real main() and it will be called from this plugin after some initial setup (as I think).

                          _eph_ Offline
                          _eph_ Offline
                          _eph
                          wrote on last edited by
                          #14

                          @KoneTaH Yeah, that doesn't work (it's looking for undefined _main).

                          Btw. I needed to force load the ios plugin and use _qt_main_wrapper for the app to work at all.

                          1 Reply Last reply
                          0
                          • _eph_ _eph

                            Yes, so if I just create simple qml - using your example:

                            #import <QQuickView>
                            #include <QtPlugin>
                            Q_IMPORT_PLUGIN(QtQuick2Plugin)
                            #endif
                            
                            int main(int argc, char *argv[])
                            {
                                QGuiApplication app(argc, argv);
                                
                                QQuickView *view = new QQuickView;
                                view->setSource(QUrl::fromLocalFile("/tmp/simple.qml"));
                                view->showFullScreen();
                                
                                return app.exec();
                            }
                            

                            and the QML:

                            import QtQuick 2.0
                            
                            Rectangle {
                                id: page
                                width: 300; height: 200
                                color: "yellow"
                            
                                Text {
                                    id: helloText
                                    text: "Hello world!"
                                    y: 30
                                    anchors.horizontalCenter: page.horizontalCenter
                                    font.pointSize: 24; font.bold: true
                                }
                            }
                            

                            This is the result:
                            0_1552871529629_Simulator Screen Shot - iPhone XR - 2019-03-18 at 13.06.58.png

                            J.HilkJ Offline
                            J.HilkJ Offline
                            J.Hilk
                            Moderators
                            wrote on last edited by
                            #15

                            @_eph
                            I would suggest using a proper Windowas the root item instead of a rectangle or something like that
                            https://doc.qt.io/qt-5/qml-qtquick-window-window.html

                            and do not set a width or height for the root item. it should scale automatically - except for "safe zones"


                            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                            Q: What's that?
                            A: It's blue light.
                            Q: What does it do?
                            A: It turns blue.

                            _eph_ 1 Reply Last reply
                            0
                            • Shrinidhi UpadhyayaS Offline
                              Shrinidhi UpadhyayaS Offline
                              Shrinidhi Upadhyaya
                              wrote on last edited by
                              #16

                              Hi @_eph , you need to have proper splash screen, otherwise your app comes like this, so every Iphone has a different size for the splash screen, so you need to prepare a splash screen with respect to the device you are deploying on and after that you need to include it in a file called info.plist, same is the case with app icons also.

                              For more info you can have a look into this: -[https://doc.qt.io/qt-5/ios-platform-notes.html]

                              For info on the sizes you can have a look at this:- [https://developer.apple.com/design/human-interface-guidelines/ios/icons-and-images/launch-screen/]

                              I guess once you have proper splash screen,the app will cover the complete Iphone screen.

                              Shrinidhi Upadhyaya.
                              Upvote the answer(s) that helped you to solve the issue.

                              _eph_ 2 Replies Last reply
                              0
                              • J.HilkJ J.Hilk

                                @_eph
                                I would suggest using a proper Windowas the root item instead of a rectangle or something like that
                                https://doc.qt.io/qt-5/qml-qtquick-window-window.html

                                and do not set a width or height for the root item. it should scale automatically - except for "safe zones"

                                _eph_ Offline
                                _eph_ Offline
                                _eph
                                wrote on last edited by
                                #17

                                @J.Hilk Makes no difference the QML is always contained in the same window/rectangle you see on the first screenshot.

                                1 Reply Last reply
                                0
                                • Shrinidhi UpadhyayaS Shrinidhi Upadhyaya

                                  Hi @_eph , you need to have proper splash screen, otherwise your app comes like this, so every Iphone has a different size for the splash screen, so you need to prepare a splash screen with respect to the device you are deploying on and after that you need to include it in a file called info.plist, same is the case with app icons also.

                                  For more info you can have a look into this: -[https://doc.qt.io/qt-5/ios-platform-notes.html]

                                  For info on the sizes you can have a look at this:- [https://developer.apple.com/design/human-interface-guidelines/ios/icons-and-images/launch-screen/]

                                  I guess once you have proper splash screen,the app will cover the complete Iphone screen.

                                  _eph_ Offline
                                  _eph_ Offline
                                  _eph
                                  wrote on last edited by
                                  #18

                                  @Shrinidhi-Upadhyaya Hm, I don't really see connection between the launch image (splascreen) and the actual app since you don't need that kind of thing when you use Qt Creator and qmake but I will try it anyway. Thanks

                                  K 1 Reply Last reply
                                  0
                                  • _eph_ _eph

                                    @Shrinidhi-Upadhyaya Hm, I don't really see connection between the launch image (splascreen) and the actual app since you don't need that kind of thing when you use Qt Creator and qmake but I will try it anyway. Thanks

                                    K Offline
                                    K Offline
                                    KoneTaH
                                    wrote on last edited by
                                    #19

                                    @_eph Do you have some minimal CMake project with this issue somewhere in public? Usually I don't use CMake, but I can take a look (as well as others, I think).

                                    _eph_ 1 Reply Last reply
                                    0
                                    • Shrinidhi UpadhyayaS Shrinidhi Upadhyaya

                                      Hi @_eph , you need to have proper splash screen, otherwise your app comes like this, so every Iphone has a different size for the splash screen, so you need to prepare a splash screen with respect to the device you are deploying on and after that you need to include it in a file called info.plist, same is the case with app icons also.

                                      For more info you can have a look into this: -[https://doc.qt.io/qt-5/ios-platform-notes.html]

                                      For info on the sizes you can have a look at this:- [https://developer.apple.com/design/human-interface-guidelines/ios/icons-and-images/launch-screen/]

                                      I guess once you have proper splash screen,the app will cover the complete Iphone screen.

                                      _eph_ Offline
                                      _eph_ Offline
                                      _eph
                                      wrote on last edited by
                                      #20

                                      @Shrinidhi-Upadhyaya OMG, you are the man! It really helped, I can't believe it lol. Adding a dummy launch storyboard made it go fullscreen... Unbelievable

                                      1 Reply Last reply
                                      0
                                      • K KoneTaH

                                        @_eph Do you have some minimal CMake project with this issue somewhere in public? Usually I don't use CMake, but I can take a look (as well as others, I think).

                                        _eph_ Offline
                                        _eph_ Offline
                                        _eph
                                        wrote on last edited by
                                        #21

                                        @KoneTaH I don't unfortunately - it's a very complex project with lots of subprojects and libraries. I could probably share the toolchain file but looks like I might have figured it out thanks to @Shrinidhi-Upadhyaya

                                        1 Reply Last reply
                                        0
                                        • Shrinidhi UpadhyayaS Offline
                                          Shrinidhi UpadhyayaS Offline
                                          Shrinidhi Upadhyaya
                                          wrote on last edited by
                                          #22

                                          Cooool!!, you are always welcome @_eph , can you mark [SOLVED] to the thread title.

                                          Shrinidhi Upadhyaya.
                                          Upvote the answer(s) that helped you to solve the issue.

                                          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