[Qt] was: Storing custom data in QWidget

Jesus Reyes jesusrmx at yahoo.com.mx
Fri Dec 29 08:40:15 CET 2006


Sorry for starting a new thread.

I was trying to find a solution, think I found one. Since version 4.2
support for dynamically added properties was added to QT.

it's something like this:
  Widget := Q(SPECIFIC_WIDGET_HERE)_Create(Parent);
  Vhandle := QVariant_Create(Cardinal(WinControl));
  QObject_setProperty(QObjectH(Widget), 'lclobject', VHandle);

then, when querying for the focus:

  Widget:=QApplication_FocusWidget();
  V := QVariant_Create;
  QObject_property(QObjectH(Widget), V, 'lclobject');
  if not QVariant_isNull(V) and QVariant_isValid(V) then begin
    WinC:=TWinControl(QVariant_toUint(v, @ok));
    if ok then 
      WriteLn('Focused control is ', WinC.Name);
  end;
  QVariant_destroy(v);

This means that we can have a direct map in both ways between the
underlaying qt WidgetH and the LCL object, I tried this option and it
works as expected.

What do you guys think, can this be used? if affirmative there needs
to be some changes so any TQtXXXX object does this setup after the
specific widget type has been created, currently the constructors
doesn't call inherited.

Jesus Reyes A.


__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
Regístrate ya - http://correo.yahoo.com.mx/ 



More information about the Qt mailing list