Ask Your Question

where in the rqt source code is the tab handling?

asked 2015-07-17 09:40:32 -0500

sam_123 gravatar image

updated 2015-07-17 14:44:29 -0500


I would like to know where I can find the rqt perspective tab handling, e.g. where in the source code are they created?

I guess it's somewhere in the qt_gui_core ( ), but I couldn't find anything.

edit: I mean the tabs in the picture below (open rqt and add some plugins over each other):

image description

Explanation of my goal: I want to add several rqt plugins (mostly my own plugins), add them to a single rqt perspective and create tabs like in the picture above. Then I want do switch between this tabs from a ros node, depending on which tab is most relevant.

edit retag flag offensive close merge delete


What do you mean by tab handling? The plugins? Or Tabs? Like in Browser? The ones like in browser are done by Qt it is not in the source of rqt.

cyborg-x1 gravatar image cyborg-x1  ( 2015-07-17 09:50:37 -0500 )edit

yes I meant tabs like in the browser. Ok, than I guess it's impossible to switch between these tabs from a ros node.

sam_123 gravatar image sam_123  ( 2015-07-17 10:17:39 -0500 )edit

Well then, have fun ;-)

cyborg-x1 gravatar image cyborg-x1  ( 2015-07-18 03:15:51 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2015-07-17 14:17:03 -0500

kramer gravatar image

As @cyborg-x1 mentioned, the tabbing functionality is part of Qt.

For the following, first, a disclaimer: the UIs I've implemented have used librviz, not rqt, so I've never had to worry about inter-widget communication (I created and set up the QMainWindow myself). Also, all my Qt work has been strictly in C++; any pyQt is possibly different. And, rqt may incorporate/hide/expose functionality that makes everything below irrelevant...I just don't know. With that said...perhaps it'll be of assistance.

The Qt QMainWindow provides the ability to tabify QDockWidgets. When a QDockWidget's docking location changes, it emits a dockLocationChanged signal; with an appropriate Qt 'connection' to a slot, one can program reactions to widget relocations.

Through various (rather convoluted) means, you can programmtically manipulate QDockWidgets through the QMainWindow. Not the easiest item to access, but I've successfully retrieved it in an RViz Display subclass via the following:

QMainWindow* main = static_cast<qmainwindow*>(context_->getWindowManager()->getParentWindow());

where context_ is an (inherited from Display) instance of rviz::DisplayContext (as implemented by the rviz::VisualizationManager).

I don't recommend going down this path, but if you do, that should give you a bit of a start on what will be involved.

edit flag offensive delete link more


I extended my post to explain a bit better what I want

sam_123 gravatar image sam_123  ( 2015-07-17 14:56:01 -0500 )edit

so if I understand you right, the best approach would be to create my own QMainWindow and add there my rqt plugins in a QDockWidget, right? Do you know how I can do that (all my rqt plugins are in C++)?

sam_123 gravatar image sam_123  ( 2015-07-17 15:03:59 -0500 )edit

Here's my understanding of what you want: to be able to programatically choose which tab is showing (based on relevance, as defined by you). What you need, then, is some way to reference and select a particular tab widget. This is not a trivial task. (More in next comment...)

kramer gravatar image kramer  ( 2015-07-17 17:35:26 -0500 )edit

I do not know if rqt provides the functionality you desire. I do know that I've done similar things in my own Qt UI. I do know that you can obtain a reference to QMainWindow in an RViz Display (and then manipulate the DockWidgets). I can't determine the 'best' approach here...but it won't be easy.

kramer gravatar image kramer  ( 2015-07-17 17:40:30 -0500 )edit

In case this isn't clear: an rqt plugin is, at root, a Qt QDockWidget. The issue is that rqt provides a container for plugins -- the widgets do not 'know' about each other, and the container may not provide a way to access them. If that's correct, any workaround requires (not easy) hacking.

kramer gravatar image kramer  ( 2015-07-17 17:53:14 -0500 )edit

Now that I think more about it -- you might be able to avoid your issue by consolidating into one plugin, using a QTabWidget in there. Each of your current plugins would become a tab in your single new rqt plugin, to be manipulated as you like...

kramer gravatar image kramer  ( 2015-07-17 18:03:26 -0500 )edit

answered 2015-07-17 10:46:45 -0500

updated 2015-07-18 02:48:03 -0500

If you want to have tabs, the source for the tabs would be in the sources for Qt framework which is used by rqt.

Update: I would also say you should add the tabs in a single plugin instead of doing the approach by messing arround in rqt. If you want to be able to disable functionality (tabs) then I would do it by having a special tab or dialog, where you can select which tabs you want to show and save this in the perspective file in the parameters of your plugins. I do not know if there is a tutorial for these, I just checked the code of the plugins for seeing that this is possible. (I will also doing that in my rqt plugin, I have tabs for settings there).

The other approach is (as also said) ... well .... , like a path through a very dark and deep ugly valley ... I guess...

edit flag offensive delete link more


I added a picture in my first post, where you can see the tabs I mean. You can do them by open rqt and adding several rqt plugins, then move them on top of each other.

sam_123 gravatar image sam_123  ( 2015-07-17 14:39:53 -0500 )edit

Well, I don't wanna lose the advantage of the ability to combine different plugins. Not every project / setup needs the same plugins, so combining all of them in a single rqt plugin isn't really the way I wanna go. I'll try the "dark valley", if something useful comes out of it, I'll post it here.

sam_123 gravatar image sam_123  ( 2015-07-18 03:12:00 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-07-17 09:40:32 -0500

Seen: 462 times

Last updated: Jul 18 '15