Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Changed UI Style when running as a daemon

Changed UI Style when running as a daemon

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 1.7k 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.
  • T Offline
    T Offline
    tnrgus
    wrote on last edited by
    #1

    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.

    • when running the application in the Foreground
      !http://img15.imageshack.us/img15/9048/52569271.png(foreground)!
    • when running as a daemon
      !http://img831.imageshack.us/img831/67/initui.png(daemon)!

    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.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tnrgus
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tzander
          wrote on last edited by
          #4

          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.

          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