Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML Filedialog Translation
Forum Updated to NodeBB v4.3 + New Features

QML Filedialog Translation

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 217 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.
  • I Offline
    I Offline
    ihmc
    wrote on last edited by
    #1

    Hi, I am using QtQuick to develop a small MS Windows application that allows dynamic translation, e.g. en, fr, de.
    In translation, it is fine with the custom .qml files with the .ts. However, when using FileDialog, no matter how I installed the QTranslator with the qt_.qm, qtbase_.qm ...etc. it is not translated. The UI is translated but the FileDialog does not. I have to change the system locale and reboot the machine and QTranslator is not necessary at this time.

    I tried to use QFileDialog (the QtWidget), the content can be changed with the QTranslator with qt_*.qm files.

    Is it a bug in Qt ?

    My setup:
    -Qt 5.14
    -Windows 10
    -MSVC 2017

    main.cpp

    ...
        QString locale = "fr";// QLocale::system().name();
        QTranslator translator;
        if ( translator.load(QString("qt_") + locale)){
            app.installTranslator(&translator);
        }else{
            return -1;
        }
        QTranslator qtBaseTranslator;
        if (qtBaseTranslator.load("qtbase_" + locale)){
            app.installTranslator(&qtBaseTranslator);
        }else{
            return -1;
        }
    ...
    

    main.qml

    import QtQuick 2.14
    import QtQuick.Window 2.14
    import QtQuick.Controls 2.13
    import QtGraphicalEffects 1.0
    import QtQuick.Dialogs 1.3
    
    Window  {
        id: window
        visible: true
        width: 1280
        height: 720
        color: "yellow"
        title: qsTr("Hello World!")
    ...
    
                      FileDialog {
                            id: fileDialog
                            title: qsTr("Please choose a file")
                            folder: shortcuts.desktop
                            selectMultiple: true
                            nameFilters: ["All (*)"]
                            onAccepted: {
                                console.log("GG")
                            }
                            onRejected: {
                                console.log("gg")
                            }
                        }
    ...
    
    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