WinRT Filepicker and CX



  • Hello,

    I am writing a mobile application(using QT5.7 with VC2015) for WP8.1/Android/iOS, and I would need to have a FilePicker/FileDialog.

    For that I tried to use the example code from Microsoft:

    FileOpenPicker^ openPicker = ref new FileOpenPicker();
    openPicker->ViewMode = PickerViewMode::Thumbnail;
    openPicker->SuggestedStartLocation = PickerLocationId::PicturesLibrary;
    openPicker->FileTypeFilter->Append(".jpg");
    openPicker->FileTypeFilter->Append(".jpeg");
    openPicker->FileTypeFilter->Append(".png");
    
    openPicker->PickSingleFileAndContinue();
    

    but when I run the application, I get the following Exception:

    The application called an interface that was marshalled for a different thread.
    WinRT information: The application called an interface that was marshalled for a different thread.
    

    And also I don't know how to get the result, use the CX async stuff together with QT

    Thanks



  • Hi, maybe this Stackoverflow link will help



  • As soon as you see this error message:
    "
    The application called an interface that was marshalled for a different thread.
    WinRT information: The application called an interface that was marshalled for a different thread.
    "
    It implies that the call itself has to be called from the Xaml Thread. Basically anything which does something visually will need to execute there.

    Out of curiosity, why are you not using QFileDialog? In any case you can see its implementation (also how to invoke things on the xaml thread) here:
    http://code.qt.io/cgit/qt/qtbase.git/tree/src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp#n245



  • First of all sorry for my very late reply, totally forgot about this forum.

    I tried to use the QFileDialog from QtWidgets with my QtQuick application, but when closing the filepicker the app stays frozen .
    Actually I have similar problems with all the CX async stuff, not calling the callback function.



Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.