ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

RQT Multiple UI files

asked 2014-01-22 07:27:26 -0500

heyfred gravatar image

updated 2014-04-20 14:09:50 -0500

ngrennan gravatar image

I am trying to create a GUI for my robot using the rqt package and I want to be able to change the display when a button is clicked.

I've got it working with one ui file but can't seem to change the ui files over. I can make the ui disappear completely but I can't get the second one to appear.

Does anyone have any experience using rqt or any suggestions that might help?


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-09-12 06:31:43 -0500

Dorian Scholz gravatar image

I assume you have read the rqt Python plugin tutorial:

There a UI file is loaded into self._widget which is then added to the main window. What you want to achieve now is to switch the contents of this widget. This is not anymore rqt specific, but a (Py)Qt question. Also there are multiple solutions to this, I think this one found here is what you want:

The accepted answer tells you to use QStackedWidget with multiple widgets (each loaded from its own UI file) and switch between them:

In you case that would mean creating a QStackedWidget as self._widget and then adding you UI based widgets to it:

self._widget = QStackedWidget()
uiWidget1 = QWidget()
loadUi(ui_file1, uiWidget1)
uiWidget2 = QWidget()
loadUi(ui_file1, uiWidget2)

And then use the setCurrentIndex or setCurrentWidget methods of QStackedWidget to switch widgets in your callback function:

edit flag offensive delete link more

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: 2014-01-22 07:27:26 -0500

Seen: 735 times

Last updated: Sep 12 '14