[Qt] Trying to implement Trayicon for Qt
Paul Ishenin
ip at kmiac.ru
Wed Sep 5 03:07:44 CEST 2007
Felipe Monteiro de Carvalho wrote:
[skip]
>
> function TWidgetTrayIcon.CreateIcon: QIconH;
> var
> Pixmap: QPixmapH;
> begin
> if Self.Icon.Handle <> 0 then
> begin
> QPixmap_fromImage(Pixmap, TQtImage(Self.Icon.Handle).Handle);
>
> Result := QIcon_create(Pixmap); // Crash here
> end
> else
> Result := QIcon_create();
> end;
You forget to allocate QPixmapH and deallocate it after. I fixed and
checked under windows it works now. Btw, under windows there are other
problems with compilation - check your ifdefs for windows case.
> I also get a crash when setting the popup menu:
>
> IconHandle := CreateIcon;
>
> SystemTrayIcon := TQtSystemTrayIcon.create(IconHandle);
>
> Text := UTF8Decode(Hint);
> SystemTrayIcon.setToolTip(Text);
>
> if Assigned(PopUpMenu) then
> if TQtMenu(PopUpMenu.Handle).Widget <> nil then
> SystemTrayIcon.setContextMenu(QMenuH(TQtMenu(PopUpMenu.Handle).Widget));
> // Crash
>
No crash here after fixing first problem (maybe it was crash because of
IconHandle pointed to empty icon?)
Please retest after commit.
Best regards,
Paul Ishenin.
More information about the Qt
mailing list