FileDialog as superuser strange behaviour

  • Hello everyone! I am developing an app on qt quick 2 with QtQuick.Controls and QtQuick.Dialogs.

    My program needs root privileges to solve some tasks. When I run my program as a normal user and open FileDialog, I see this: ! dialog)!

    but when I run my app as root and open dialog, I see this:
    ! dialog)!

    this dialog is not usable, i can not select files with it.

    here is a test program listing:
    @#include <QtGui/QGuiApplication>
    #include "QtQml/QQmlApplicationEngine"
    #include "QtQml/QQmlContext"
    #include <QStyleHints>
    #include "QDebug"
    QQmlApplicationEngine* engine;

    int main(int argc, char *argv[])
    QGuiApplication app(argc, argv);
    engine = new QQmlApplicationEngine("qml/fileDialog/main.qml");
    return app.exec();

    @import QtQuick 2.1
    import QtQuick.Controls 1.0
    import QtQuick.Dialogs 1.0

    ApplicationWindow { title: qsTr("Hello World")
    width: 640; height: 480

    Button {  text: qsTr("Hello World");  anchors.centerIn: parent
        onClicked:; }
    FileDialog {
        id: projectOpenFD;title: "Выберите файл проекта или конфигурации питателей для чтения"
        nameFilters: [ "Файл проекта или конфигурации питателей (*.project *.feeders)" ]


    I am using qt 5.2 beta. running ubuntu 13.10.

    I need a normal dialog, when run as superuser! searched internet, no results so far.

  • I solved my problem.
    In the second picture it was a pure qml fileDialog. it appears if none of OS fileDialog or QtWidget fileDialog can not be opened.
    line "QGuiApplication app(argc, argv);" in my main.cpp was started pure qt quick application without qtwidget support.
    A changed it to "QApplication app(argc, argv);" and added include line "#include "QApplication"" and when I ran my program I saw QtWidget fileDialog. It works okey!

  • Your code help me! thankyou

Log in to reply