TStatusBar can define both SimpleText and panel items. SimplePanel boolean property switces between them. It works with other widgetsets but not with QT. The same problem happens at both design and run time. I planned to fix it and create a patch... yes, that was the plan...
If SimplePanel = False initially, panels are shown, then you can switch it to True and you get the SimpleText. After that nothing happens, the same SimpleText shows always.
Then I noticed, if SimpleText = '' then the switching works. So I tied to fix TQtWSStatusBar.RecreatePanels like this: (see "added line")
class procedure TQtWSStatusBar.RecreatePanels(const AStatusBar: TStatusBar;
const Widget: TQtStatusBar);
var
Str: WideString;
i: Integer;
begin
ClearPanels(Widget);
if AStatusBar.SimplePanel then
begin
Str := GetUtf8String(AStatusBar.SimpleText);
Widget.showMessage(@Str);
end else
if AStatusBar.Panels.Count > 0 then
begin
Str := ''; Widget.showMessage(@Str); // <-- added line !!!
Widget.setUpdatesEnabled(False);
SetLength(Widget.Panels, AStatusBar.Panels.Count);
for i := 0 to AStatusBar.Panels.Count - 1 do
begin
Str := GetUtf8String(AStatusBar.Panels[i].Text);
Widget.Panels[i] := TQtStatusBarPanel.CreateFrom(AStatusBar,
QLabel_create(@Str, Widget.Widget));
Widget.Panels[i].HasPaint := AStatusBar.Panels[i].Style = psOwnerDraw;
Widget.Panels[i].ID := AStatusBar.Panels[i].ID;
QLabel_setText(QLabelH(Widget.Panels[i].Widget), @Str);
QLabel_setAlignment(QLabelH(Widget.Panels[i].Widget),
AlignmentToQtAlignmentMap[AStatusBar.Panels[i].Alignment]);
QWidget_setMinimumWidth(Widget.Panels[i].Widget,
AStatusBar.Panels[i].Width);
Widget.Panels[i].AttachEvents;
Widget.addWidget(Widget.Panels[i].Widget, ord(i =
AStatusBar.Panels.Count - 1));
end;
Widget.setUpdatesEnabled(True);
end;
end;Didn't help. Then I thought I will create the panel like the other panels are created. Like this:
...
ClearPanels(Widget);
if AStatusBar.SimplePanel then
begin
Str := GetUtf8String(AStatusBar.SimpleText);
Widget.Panels[0] := TQtStatusBarPanel.CreateFrom(AStatusBar,
QLabel_create(@Str, Widget.Widget));
Widget.Panels[0].ID := AStatusBar.Panels[0].ID;
QLabel_setText(QLabelH(Widget.Panels[0].Widget), @Str);
Widget.addWidget(Widget.Panels[0].Widget, 1);
end else
...Didn't help either. It works as well as the earlier version though. How can you Zeljan make such binding code work? Uhhh!
Regards,
Juha
