Home | Tutorials | Wiki | Issues
Ask Your Question
0

Where is the style.qss in the OS? Is it possible to customize the gzclient menus at runtime?

asked 2019-11-11 16:27:11 -0600

Ruben gravatar image

updated 2019-11-12 14:57:56 -0600

Hi all,

I'm trying to customize the gzclient menus.

I see the menus are added on MainWindow.cc

It seems they are customized at runtime by loading the :/style.qss file at runtime.

I tried to find that file in the osrf/ros:kinetic-desktop-full docker with find / -name style.qss but I couldn't find the file.

Does anybody know where that file is located? I didn't understand the : in the filename when loading with QFile file(":/style.qss");

PS: I saw a similar question, but there was no answer there, that is why I asked here.


EDIT 1: Thanks to @chapulina we have the custom_gazebo_style that should do the job.

However, to be able to Compile I had to modify the CMakeLists.txt to:

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_FLAGS "-std=c++11")

find_package(Qt5Core REQUIRED)
find_package(Qt5X11Extras REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(gazebo REQUIRED)

QT5_ADD_RESOURCES(resources_RCC resources.qrc)

include_directories(SYSTEM ${GAZEBO_INCLUDE_DIRS})
link_directories(${GAZEBO_LIBRARY_DIRS})

add_library(custom_gazebo_style SHARED
  CustomGazeboStyle.cc
  ${resources_RCC}
)
target_link_libraries(custom_gazebo_style ${GAZEBO_LIBRARIES}
    ${Qt5Widgets_LIBRARIES}
    ${Qt5X11Extras_LIBRARIES}
    ${Qt5Gui_LIBRARIES}
    ${Qt5Core_LIBRARIES}
    ${Qt5Widgets_LIBRARIES})

I modified because of the 5 errors below:

  1. /usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.

  2. /usr/include/gazebo-7/gazebo/gui/qt.h:23:17: fatal error: QtGui: No such file or directory

  3. /usr/include/gazebo-7/gazebo/gui/qt.h:24:20: fatal error: QX11Info: No such file or directory

  4. /usr/include/gazebo-7/gazebo/gui/qt.h:24:20: fatal error: QX11Info: No such file or directory

  5. /usr/include/gazebo-7/gazebo/gui/qt.h:25:19: fatal error: QWidget: No such file or directory

I'm probably missing something.

After the modifications on CMakeLists.txt everything compiled, but I couldn't load the plugin. If I call gazebo worlds/empty.world --gui-plugin $(pwd)/libcustom_gazebo_style.so --verbose the program finishes right away with code 255.

If I run gzserver instead of gazebo (using the same parameters) and then launch gzclient (also with the same parameters), gzclient crases with Segmentation fault (core dumped).

I checked there was no other gzclient running and GAZEBO_MASTER_URI=http://localhost:11345.

Well, maybe is the version 7.16.0 I'm using with Docker. I may try a different gazebo version to see whether the error goes away.


EDIT 2:

With gazebo 9.0.0, the custom_gazebo_style works like a charm.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2019-11-11 16:41:10 -0600

Ruben gravatar image

Hm, the style.qss that is found in resources.qrc is "compiled" inside the binary as explained in Qt documentation.

If I understood well, I basically have to recompile the client after modifying the style.qss.

edit flag offensive delete link more
1

answered 2019-11-11 20:21:45 -0600

chapulina gravatar image

Your answer is correct that style.qss is compiled within Gazebo and therefore it's not just a matter of finding the file and editing it.

But this doesn't mean you can't change the style some other way. I created an example GUI plugin here which loads a custom QSS file at runtime ๐Ÿ˜‰

edit flag offensive delete link more

Comments

Hi @chapulina,

Thanks for pointing me to the custom_gazebo_style

In Kinetic Docker I'm using gazebo-7.16.0 and to correctly compile, I had to modify the CMakeLists.txt, but I can't add the content here because of the characters limit. I edited the question to add the modified CMakeLists.txt and my results.

Ruben gravatar imageRuben ( 2019-11-12 11:16:05 -0600 )edit

Thank you for the changes! I pushed a few of them to the repository and it still works with gazebo9. Maybe the others are not strictly necessary for gazebo7? Feel free to open a pull request with any further changes you may need ;)

chapulina gravatar imagechapulina ( 2019-11-12 12:17:18 -0600 )edit
1

I now tried with gazebo 9.0.0 and it works like a charm. Ok, I'll add a pull request if I manage to make it work with gazebo 7. Thank you very much for having dedicated time to this.

Ruben gravatar imageRuben ( 2019-11-12 14:55:56 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-11-11 16:27:11 -0600

Seen: 53 times

Last updated: Nov 12