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. FileDialog on iOS only works in portrait mode. Crashes otherwise.
QtWS25 Last Chance

FileDialog on iOS only works in portrait mode. Crashes otherwise.

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
4 Posts 2 Posters 1.2k 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.
  • D Offline
    D Offline
    Dogmaphobic
    wrote on last edited by
    #1

    If I set FileDialog's folder to shortcuts.pictures when the app is in landscape mode, it flips to portrait mode before showing the OS builtin image picker. If the app is set to only use Landscape mode, Qt crashes:

    MyApp[808:282060] *** Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [PUUIAlbumListViewController shouldAutorotate] is returning YES'
    

    Is this a bug or am I missing something?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Can you provide a minimal compilable example that shows that behavior ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      D 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Can you provide a minimal compilable example that shows that behavior ?

        D Offline
        D Offline
        Dogmaphobic
        wrote on last edited by
        #3

        @SGaist Just create anything using Qt Creator's wizard:

        main.cpp

        #include <QGuiApplication>
        #include <QQmlApplicationEngine>
        
        int main(int argc, char *argv[])
        {
            QGuiApplication app(argc, argv);
            QQmlApplicationEngine engine;
            engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
            return app.exec();
        }
        

        main.qml

        import QtQuick 2.7
        import QtQuick.Window 2.2
        import QtQuick.Dialogs  1.2
        import QtQuick.Controls 1.3
        
        Window {
            visible: true
            width: 640
            height: 480
            title: qsTr("Hello World")
            FileDialog {
                id:             filePicker
                title:          "Please choose an image file"
                folder:         shortcuts.pictures
                visible:        false
                nameFilters:    [ "Image files (*.jpg *.png)", "All files (*)" ]
                onAccepted: {
                    console.log("You picked: " + filePicker.fileUrl()
                    filePicker.close()
                }
            }
            Button {
                anchors.centerIn: parent
                text: "Pick An Image"
                onClicked: {
                    filePicker.open()
                }
            }
        }
        

        Note that you need to add some keys to the .plist file. Either through Xcode or creating your own .plist and adding to your .pro file.

        	<key>NSPhotoLibraryUsageDescription</key>
        	<string>Foo Bar</string>
        	<key>UISupportedInterfaceOrientations</key>
        	<array>
        		<string>UIInterfaceOrientationLandscapeLeft</string>
        		<string>UIInterfaceOrientationLandscapeRight</string>
        	</array>
        

        Everything using the latest version (Qt Creator 4.1.0, Qt 5.7, Xcode 8.0, etc.)

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Sorry, I couldn't test.

          Since there has been new releases in between can you check with them ? 5.7.1 is out and 5.8 Beta also.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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