t-artistik / qtscriptgenerator

Automatically exported from code.google.com/p/qtscriptgenerator
0 stars 0 forks source link

Lost basic functionality (such as widget.findChild()) #47

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,
The script loader seems awesome but some initial tests are confusing.
I used to load a UI and a Script to set connections etc. (fairly standard
and basic) and thought to load the script-extensions (core/gui) to extend
what I can do in the script to set up widgets in the UI such as populating
of QListWidgets etc.

However, basic functionality such as findChild() is no longer working?
What am I doing wrong?
I noticed that findChild was not among the functions for QObject in the
generator cpp's(?)

The .js and .ui are loaded and set up very much like the calculator example
for Qt like:

     QScriptEngine engine;
     QFile scriptFile("small.js");
     scriptFile.open(QIODevice::ReadOnly);
     engine.evaluate(scriptFile.readAll());
     scriptFile.close();

     QUiLoader loader;
     QFile uiFile("small.ui");
     uiFile.open(QIODevice::ReadOnly);
     QWidget *ui = loader.load(&uiFile);
     uiFile.close();

     QScriptValue ctor = engine.evaluate("Form");
     QScriptValue scriptUi = engine.newQObject(ui,
                              QScriptEngine::ScriptOwnership);
     QScriptValue calc = ctor.construct(QScriptValueList() << scriptUi);

What steps will reproduce the problem?
1. Calling SomeWidget.findChild('someChild') on a ui widget passed to the
constructor of a Form class in a script

What is the expected output? What do you see instead?
Without the loaded extensions .findChild() returns widgets.
After loading "qt.core" and/or "qt.gui" the same call seems dead and
returns nothing.

The .ui is 

What version of the product are you using? On what operating system?
qt-scriptgenerator-master (snapshot of 2009.07.28)
WindowsXP, Qt-4.5.1 compiled for VisualStudio (nmake)

Please provide any additional information below.

<small.js>
>>function Form(ui)
>>{
>>    this.ui = ui;
>>    //this.ui.myBox.setChecked(true);            //GOOD
>>    this.ui.findChild('myBox').setChecked(true); //BAD
>>}

<small.ui>
>><?xml version="1.0" encoding="UTF-8"?>
>><ui version="4.0">
>> <class>Form</class>
>> <widget class="QWidget" name="Form">
>>  <property name="geometry">
>>   <rect>
>>    <x>0</x>
>>    <y>0</y>
>>    <width>90</width>
>>    <height>36</height>
>>   </rect>
>>  </property>
>>  <property name="windowTitle">
>>   <string>Form</string>
>>  </property>
>>  <property name="autoFillBackground">
>>   <bool>true</bool>
>>  </property>
>>  <property name="styleSheet">
>>   <string notr="true"/>
>>  </property>
>>  <layout class="QVBoxLayout" name="verticalLayout">
>>   <item>
>>    <widget class="QCheckBox" name="myBox">
>>     <property name="text">
>>      <string>CheckBox</string>
>>     </property>
>>    </widget>
>>   </item>
>>  </layout>
>> </widget>
>> <resources/>
>> <connections/>
>></ui>

Original issue reported on code.google.com by steli...@gmail.com on 30 Jul 2009 at 4:01

Attachments: