Trolltech Home | QSA-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

QSA-interest Archive, November 2005
Newbie problem with qsa


Message 1 in thread

Hi

I am a new user of qsa (1.2.0 using qt 4.0.1 & snapshot 29/10). I am
having trouble using it. Actually i am just using it in a dummy app to
get a feel of it. Here is the code (shortened):

QsaTrial::QsaTrial() : QWidget(0){ //This is main window
    this->setObjectName("trial");

    m_pButton1 = new QPushButton("First", this);
    m_pButton1->setObjectName("button");

    m_pButton2 = new QPushButton("Second", this);
    m_pButton2->setObjectName("buttons");
    m_pButton2->move(20, 0);

    resize( 200, 200);

    qsProject = new QSProject(this);
    qsProject->addObject(this);

    qsInterpreter = qsProject->interpreter();
    qsInterpreter->addObject(this);

    tmr = new QTimer (this);
    connect(tmr, SIGNAL(timeout()), this, SLOT(tmrHandler()));
    tmr->start(5000);
}

void QsaTrial::tmrHandler(){
    qsInterpreter->evaluate("trial.button.visible = !trial.button.visible;");
    qsInterpreter->evaluate("trial.buttons.visible = !trial.buttons.visible;");
}

Problem with the above code is that only the button which is
initialised first is available to the script. e.g. in the above code
"Error: Trying to access undefined member 'buttons'" is generated.

If m_pButton2 is initialised first then 'buttons' is available in qsa
but 'button' is not.

I guess am not doing something usual.

Please help me.

--
 [ signature omitted ] 

Message 2 in thread

Please ignore/comment the following line in my prev mail:
 qsInterpreter->addObject(this);

Sorry for the mistake.

On 11/15/05, Yogesh M <yogeshm02@xxxxxxxxx> wrote:
> Hi
>
> I am a new user of qsa (1.2.0 using qt 4.0.1 & snapshot 29/10). I am
> having trouble using it. Actually i am just using it in a dummy app to
> get a feel of it. Here is the code (shortened):
>
> QsaTrial::QsaTrial() : QWidget(0){ //This is main window
>     this->setObjectName("trial");
>
>     m_pButton1 = new QPushButton("First", this);
>     m_pButton1->setObjectName("button");
>
>     m_pButton2 = new QPushButton("Second", this);
>     m_pButton2->setObjectName("buttons");
>     m_pButton2->move(20, 0);
>
>     resize( 200, 200);
>
>     qsProject = new QSProject(this);
>     qsProject->addObject(this);
>
>     qsInterpreter = qsProject->interpreter();
>     qsInterpreter->addObject(this);
>
>     tmr = new QTimer (this);
>     connect(tmr, SIGNAL(timeout()), this, SLOT(tmrHandler()));
>     tmr->start(5000);
> }
>
> void QsaTrial::tmrHandler(){
>     qsInterpreter->evaluate("trial.button.visible = !trial.button.visible;");
>     qsInterpreter->evaluate("trial.buttons.visible = !trial.buttons.visible;");
> }
>
> Problem with the above code is that only the button which is
> initialised first is available to the script. e.g. in the above code
> "Error: Trying to access undefined member 'buttons'" is generated.
>
> If m_pButton2 is initialised first then 'buttons' is available in qsa
> but 'button' is not.
>
> I guess am not doing something usual.
>
> Please help me.
>
> --
> Yogesh M
> Chandigarh, India
>


--
 [ signature omitted ]