Hi,
I am trying to implement TTrayIcon for the Qt widgetset, but some things just don't work, and I don't know why ...
You can test this by using the lazarus/components/example/wndtray.lpi test project. The test project doesn't require installing the package to be used (the package is visual, and rebuilding the ide is time consuming, so I decided for this way).
Basically you assign a icon and a popup menu to the trayicon, and it maps this to the widgetset. The qt implementation is on wsqttrayicon.pas
On this same file, on this function, I get a crash, because QPixmapIsNull according to the message. But debugging I see that Pixmap isn't nil. The Icon is loaded from a icon.ico image file.
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;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));
// CrashThe TTrayIcon example works on Windows and on Gtk, so I would say that the LCL side is correct, and the icons and popup menus are assigned.
Sorry for such a generic report, but I have no idea what is going wrong ....
The SystemTrayIcon class is a simple mapping of the QSystemTrayIcon methods, so it doesn't influence much here.
thanks,
