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

QSA-interest Archive, October 2005
Problem with return a QObject * in QSA


Message 1 in thread

hi(salaam)

can i return a QObject* in a function and use it in QSA
(e.g)
QObject *MyClass::CreateObj(QString & Name, QWidget* Parent)
{
return new QPushButton(Parent, Name);
}

add a object of MyClass to QSProject
add a Widget to QSProject for Parent
and use it in QSA

btn1 = aMyClassObj.CreateObj(¨btn1¨, Application.aWidget);
btn1.flat = true;


i wrote it and do not work
when show the aWidget, btn1 is not flat

MKH
 -----------
End. 



Message 2 in thread

mkh wrote:
> can i return a QObject* in a function and use it in QSA
> (e.g)
> QObject *MyClass::CreateObj(QString & Name, QWidget* Parent)
> {
> return new QPushButton(Parent, Name);
> }
> 
> add a object of MyClass to QSProject
> add a Widget to QSProject for Parent
> and use it in QSA
> 
> btn1 = aMyClassObj.CreateObj(¨btn1¨, Application.aWidget);
> btn1.flat = true;
> 
> 
> i wrote it and do not work
> when show the aWidget, btn1 is not flat
> 

Hi, MKH.

The following code works for me with QSA 1.1.3 and Qt 3.3.5. I have also
verified that the corresponding code in QSA 1.2.0 works, with and 
without Qt3 support. Are there any obvious, conceptual differences here, 
compared to what you were hoping to achieve?

--
 [ signature omitted ] 

Message 3 in thread

hi
thanx
it's work

MKh
"Eskil A. Blomfeldt" <eblomfel@xxxxxxxxxxxxx> wrote in message
news:divraa$84e$1@xxxxxxxxxxxxxxxxxxxxx
> mkh wrote:
> > can i return a QObject* in a function and use it in QSA
> > (e.g)
> > QObject *MyClass::CreateObj(QString & Name, QWidget* Parent)
> > {
> > return new QPushButton(Parent, Name);
> > }
> >
> > add a object of MyClass to QSProject
> > add a Widget to QSProject for Parent
> > and use it in QSA
> >
> > btn1 = aMyClassObj.CreateObj(¨btn1¨, Application.aWidget);
> > btn1.flat = true;
> >
> >
> > i wrote it and do not work
> > when show the aWidget, btn1 is not flat
> >
>
> Hi, MKH.
>
> The following code works for me with QSA 1.1.3 and Qt 3.3.5. I have also
> verified that the corresponding code in QSA 1.2.0 works, with and
> without Qt3 support. Are there any obvious, conceptual differences here,
> compared to what you were hoping to achieve?
>
> --
> // include statements
>
> class MyClass: public QObject
> {
>      Q_OBJECT
> public:
>      MyClass(QObject *parent, const QString &name) : QObject(parent,name)
>      { }
>
> public slots:
>      QObject *CreateObj(const QString &name, QWidget *parent)
>      {
>          return new QPushButton(parent, name);
>      }
> };
>
> int main(int c, char **a)
> {
>      QApplication app(c, a);
>      QWidget w(0, "widget");
>      QSProject project;
>      MyClass myClassObject(0, "myClassObject");
>
>      project.addObject(&w);
>      project.addObject(&myClassObject);
>
>      project.interpreter()->evaluate(
>          "btn1 = Application.myClassObject.CreateObj(\"btn1\",
> Application.widget);"
>          "btn1.flat = true;");
>
>      app.setMainWidget(&w);
>      w.show();
>
>      return app.exec();
> }
>
> #include "main.moc"
> --
>
> Would you be able to try this short program with your configuration and
> see if it works for you?
>
> Also: Which version of QSA and which version of Qt are you using?
>
>
>
> best regards,
> Eskil