Qt-based Custom UI problem

Typically: "How do I... ", "How can I... " questions
engelrob
Posts: 1
Joined: 19 May 2017, 08:48

Qt-based Custom UI problem

Postby engelrob » 19 May 2017, 09:06

Hello!
I'm trying to use the Qt-based Custom UI but I don't know how to run it. The tutorial doesn't say how to execute it.

Any help will be appreciate.
Thanks in advance,
Regards.

francofusco
Posts: 9
Joined: 22 Apr 2017, 09:20

Re: Qt-based Custom UI problem

Postby francofusco » 19 May 2017, 11:30

Hi!

Basically, you just need to create the definition of the UI using the custom xml syntax. You store such information within a string and you call simExtCustomUI_create(your_xml_description). Then, remeber to call the destroy function if you do not need the UI anymore!

This is a (simple and dumb) example (in a new scene, add a non-threaded script and paste the code Inside it):

Code: Select all

function checkCB(ui_handle, item_id, is_checked)
    msg = "Checbox : "
    if is_checked==0 then msg=msg.."not " end
    msg=msg.."checked"
    simAddStatusbarMessage(msg)
end

function spinboxCB(ui_handle, item_id, new_value)
    simAddStatusbarMessage("Spinbox value : "..new_value)
end

function buttonCB(ui_handle, item_id)
    simAddStatusbarMessage("Push-button has been clicked")
end

function radio1CB(ui_handle, item_id)
    simAddStatusbarMessage("You checked the first item")
end

function radio2CB(ui_handle, item_id)
    simAddStatusbarMessage("You checked the second item")
end

ui = nil
if (sim_call_type==sim_childscriptcall_initialization) then

    xml = [[
        <ui closeable="false" title="MyQtUI" resizable="true">
            <tabs>
            <tab title="First tab">
                <checkbox text=" I am a checkbox" checked="false" onchange="checkCB"/>
                <spinbox prefix="an integer: " minimum="5" maximum="120" step="5" onchange="spinboxCB"/>
                <button text="click me" onclick="buttonCB"/>
                </tab>
            <tab title="Second tab" layout="vbox">
                <group flat="false" layout="hbox">
                    <label text="Select one:"/>
                    <radiobutton text="item 1" checked="true"  onclick="radio1CB"/>
                    <radiobutton text="item 2" checked="false" onclick="radio2CB"/>
                </group>
                <group flat="true" layout="vbox">
                    <label text="Hello, World!"/>
                    <label text="Hello, again!"/>
                </group>
                </tab>
            </tabs>
        </ui>
    ]]

    ui = simExtCustomUI_create(xml)

end


if (sim_call_type==sim_childscriptcall_actuation) then

end


if (sim_call_type==sim_childscriptcall_sensing) then

end


if (sim_call_type==sim_childscriptcall_cleanup) then

    if ui then simExtCustomUI_destroy(ui) end

end


I am quite a novice with Lua and V-Rep, so maybe someone with more experience will give you better suggestions ;)

coppelia
Site Admin
Posts: 6047
Joined: 14 Dec 2012, 00:25

Re: Qt-based Custom UI problem

Postby coppelia » 20 May 2017, 05:29

Thanks Franco,

yes, have also a look at the code of the various demo scenes or models that use custom UIs. E.g. Models/infrastructure/Floors/infiniteFloor.ttm

Cheers


Return to “General questions”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 36 guests