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: !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.0ApplicationWindow { 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.
-
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!