Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / qt / 2006-12

was: Storing custom data in QWidget

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Jesus Reyes

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/

zeljko
to Jesus Reyes
Jesus Reyes wrote
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.

hm..It doesn't look bad ;) if this is right solution to get more compatibility and easier coding then let it be.
Where are your changes for TStringGrid ?