Changed UI Style when running as a daemon



  • I am trying to create a background application using Qt.

    There is a difference of ui between running in the foreground and running as a deamon.

    I think the application in the foreground applies 'Desktop Settings' as a GUI style, but I don't know which style is used on a daemon application.

    Source code is below.

    main.cpp
    @ #include <QApplication>
    #include "form.h"

    int main(int argc, char* argv[])
    {
        QApplication app(argc, argv);
        Form *pForm = new Form();
        pForm->show();
        return app.exec();
    }@
    

    form.h
    @#include <QWidget>
    namespace Ui {
    class form;
    }

    class Form : public QWidget
    {
        Q_OBJECT
    public:
        explicit Form(QWidget *parent = 0);
    private:
        Ui::form *ui;
    };@
    

    form.cpp
    @#include "form.h"
    #include "ui_form.h"

    Form::Form(QWidget *parent) : QWidget(parent)
    , ui(new Ui::form)
    {
    ui->setupUi(this);
    ui->label->setText(QT_VERSION_STR);
    }@

    form.ui
    @<?xml version="1.0" encoding="UTF-8"?>
    <ui version="4.0">
    <class>form</class>
    <widget class="QWidget" name="form">
    <property name="geometry">
    <rect>
    <x>0</x>
    <y>0</y>
    <width>400</width>
    <height>300</height>
    </rect>
    </property>
    <property name="windowTitle">
    <string>Form</string>
    </property>
    <widget class="QPushButton" name="pushButton">
    <property name="geometry">
    <rect>
    <x>270</x>
    <y>240</y>
    <width>98</width>
    <height>27</height>
    </rect>
    </property>
    <property name="text">
    <string>PushButton</string>
    </property>
    </widget>
    <widget class="QTabWidget" name="tabWidget">
    <property name="geometry">
    <rect>
    <x>30</x>
    <y>30</y>
    <width>341</width>
    <height>191</height>
    </rect>
    </property>
    <widget class="QWidget" name="tab">
    <attribute name="title">
    <string>Tab 1</string>
    </attribute>
    </widget>
    <widget class="QWidget" name="tab_2">
    <attribute name="title">
    <string>Tab 2</string>
    </attribute>
    </widget>
    </widget>
    <widget class="QLabel" name="label">
    <property name="geometry">
    <rect>
    <x>50</x>
    <y>240</y>
    <width>141</width>
    <height>31</height>
    </rect>
    </property>
    <property name="text">
    <string/>
    </property>
    </widget>
    </widget>
    <resources/>
    <connections/>
    </ui>@

    Please let me know why the style is different.

    Thanks.



  • I guess processes running as a deamon run as a different user, and thus have different settings.

    However, I would suggest that you don't add GUI's to processes running as a deamon. Instead, create a separate application that can connect to the deamon in order to control it, show its status, etc.



  • I would like to maintain the source code by modifying a few part, but I would work the way you suggest, which create a separate GUI application.

    Thanks, Andre.

    The style has been changed since Ubuntu 11.10.
    I want to know which part has been changed since Ubuntu 11.10.



  • if you run qconfig as the user your daemon process runs as, you see the part that has been changed.

    I agree with Andre, though. Any daemon should run without a window so it can keep running if all users log out.


Log in to reply
 

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