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. FileDialog as superuser strange behaviour

FileDialog as superuser strange behaviour

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 1.4k 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
    DDDIM
    wrote on last edited by
    #1

    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: !http://s28.postimg.org/lmo8w25h9/image.png(normal dialog)!

    but when I run my app as root and open dialog, I see this:
    !http://s9.postimg.org/7b3ilvs33/image.png(normal dialog)!

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

    here is a test program listing:
    main.cpp:
    @#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();
    }
    @

    main.qml:
    @import QtQuick 2.1
    import QtQuick.Controls 1.0
    import QtQuick.Dialogs 1.0

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

    Button {  text: qsTr("Hello World");  anchors.centerIn: parent
        onClicked: projectOpenFD.open(); }
    
    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.

    ksm-intech.ru

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DDDIM
      wrote on last edited by
      #2

      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!
      !http://s17.postimg.org/ibrrnyi7z/image.png!

      ksm-intech.ru

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mhcrnl
        wrote on last edited by
        #3

        Your code help me! thankyou

        Salutare !!!

        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