[Rock-dev] Qt ruby gui for rock
Alexander Duda
Alexander.Duda at dfki.de
Sat Jan 1 21:59:12 CET 2011
Hi all,
Happy new year 2011:-).
We started a discussion about a gui for rock and the current implementation called widget_grid/widget_factory last year. I have found a nice solution for this with a seamless qt ruby / orocos.rb integration.
If all our c++ based qt widgets are implementing the QDesignerCustomWidgetInterface they can be used for the qt designer and can be loaded automatically by the ruby UILoader (this would replace almost the hole widget_factory.rb).
EXAMPLE:
app = Qt::Application.new(ARGV)
loader = Qt::UiLoader.new
#load our c++ widget
widget = loader.createWidget("ImageView")
widget.show
#ui has two ImageView widgets which are automatically loaded
file = Qt::File.new("test.ui")
file.open(Qt::File::ReadOnly)
widget = loader.load file, nil
file.close
widget.show
I thought about a nice interface for this and orocos.rb.
I suggest to re-implement the connect_to for ports and add for each widget a ruby qt/orocos interface script.
EXAMPLE
task.port.connect_to widget, :update_rate => 50, ...
the script would be something like:
def widget.display(data)
setData(data.message) # setData is a qt slot of the widget
end
I would rename WidgetGrid into QtOrocos which has the following functionality:
--> creates c++ widgets and adds their qt/orocos interface to them
--> creates rb widgets
--> knows which widget can display which port
and put it into orocos.rb because it is completely orocos.rb depended. All the widgets could go into
the gui/viz folder
QtOrocos Interface:
create_widget(name,parent)
widget_for_type(type,parent)
widget_for_port(port,parent)
widget_for_task(task,parent)
widget_for(value,port)
register_ruby_widget(widget,name)
open(ui_file_name)
Furthermore I would implement a new c++ container widget which can be used to move its child widgets around during runtime. This widget and its children can be added via qt designer or at runtime.
Any comments?
Alex
EXAMPLE:
#///////////////////////////////////////////////////////////////////////////////////////
#working with ui files
#///////////////////////////////////////////////////////////////////////////////////////
#create app out of ui
qt_app= QtOrocos.open("file.ui")
#connect ports with ui widgets
camera.frame.connect_to qt_app.viewer, :update_rate => 50, :type => :buffer, :size => 5
#or connect ports with ui widgets which do not have an orocos qt interface
camera.frame.connect_to qt_app.textfield, :update_rate => 50, :type => :buffer, :size => 5 do |widget, data|
widget.setText data.message
end
#display a new widget as independent window
widget = QtOrocos::widget_for camera.frame
camera.frame.connect_to widget
widget.show #new window
#or add a new widget to a container
widget = QtOrocos::widget_for camera.frame, :parent => qt_app.rock_container
camera.frame.connect_to widget
widget.show
qt_app.exec
#///////////////////////////////////////////////////////////////////////////////////////
#working without ui files
#///////////////////////////////////////////////////////////////////////////////////////
#creates an empty main_widget + qt Application
qt_app = QtOrocos.new
rock_container = QtOrocos::create_widget "RockContainer", qt_app
#add new widgets to the container
widget = QtOrocos::widget_for camera.frame, :parent => rock_container
camera.frame.connect_to widget
widget.show
qt_app.exec
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.dfki.de/mailman/cgi-bin/private/rock-dev/attachments/20110101/db05acb6/attachment.htm
More information about the Rock-dev
mailing list