0

I have created an app in Qt creator , when i run it in normal mode and sudo mode its colour and icons are different why it is happening , i feel in sudo mode have great look.see below images of both.

Normal Mode

Above ones is when the app running in normal mode

enter image description here

This is how it looks in sudo mode,. I need to run my application in sudo mode because it uses GPIO pins in raspberry pi. But running in sudo mode provide a warning that QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root' when running sudo commands

and my QSettings file is saving in some where in root folder. To avoid this (so that settings file will save in .config folder) i started my app using following command

sudo -E ./MyApp

So the environment variable is preserved and QSettings are saved in .config folder, but the app looks like normal mode (first picture).

So my question is -How can I preserve the environment variable and same time app looks like sudo mode (second picture)?

i am using c++ in Qtcreator (qt5) for app creation in raspberry pi os

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Arun K
  • 413
  • 4
  • 15

1 Answers1

1

Hai I got the answer start the app with following command

sudo --preserve-env=XDG_RUNTIME_DIR ./MyApp

Above command satisfied my both conditions

Arun K
  • 413
  • 4
  • 15