Sign in Join

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

Mailing lists / qt / 2010-03

QT binding anomalies

14 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Juha Manninen

Zeljko:

I closed issue 0015744: QT version of Lazarus gives Access Violation when deleting items from Watches list during debugging.

Thanks for fixing it!

Now, I would like to know what was the fundamental difference between our QT libs? Is it just a version difference? If so, then it is OK. However I understood you had tested QT4.6 already before it was published. I tested with QT4.5 and QT4.6 myself and had the same problem. If there are random differenced between distros or window managers then the situation is bad. The bindings will never work correctly everywhere.

There were other similar differences between our systems, like the editor cursor which disappeared after scroll. Finally you fixed it so I guess you could reproduce it, too. What was the difference then?

The issue
"0015885: QT Combobox flickers when updating items list" still remains. I don't know if a screencast can catch it but it is very obvious. I must believe it doesn't happen in your system if you don't see it. I am already propared to test the original QT lib from Nokia (in case OpenSuse has tweaked it) and test a different window manager. It just feels strange because my system has no other problems related to drawing.

Regards,
Juha

Reply by email

zeljko
to Juha Manninen
Juha Manninen wrote 13 lines
Zeljko: I closed issue 0015744: QT version of Lazarus gives Access Violation when deleting items from Watches list during debugging. Thanks for fixing it! Now, I would like to know what was the fundamental difference between our QT libs? Is it just a version difference? If so, then it is OK. However I understood you had tested QT4.6 already before it was published. I tested with QT4.5 and QT4.6 myself and had the same problem. If there are random differenced between distros or window managers then the situation is bad. The bindings will never work correctly everywhere.

There's "big" difference between my devel system and yours :) 1.My system is glibc 2.3.4 based (fedora 3) with few dozen pacakges created by me (eg. kernel is 2.6.26)
2.XOrg is 6.8.2 and there's BIG diff between XOrg < 7.0 and >= 7.0 3.My qt version is 4.5.3 but compiled (and packaged) by me with -no-sse since it segfaults imediatelly on glibc < 2.4 because of glibc 2.3.XX bugs. 4.I've tested 4.6.GIT yesterday and it works ok.
5.Bindings are ok :)

There were other similar differences between our systems, like the editor cursor which disappeared after scroll. Finally you fixed it so I guess you could reproduce it, too. What was the difference then?

Cursor problem wasn't visible to me since my XOrg is 6.8.2 and I have pretty fast machine.

Show quoted text 9 lines
The issue "0015885: QT Combobox flickers when updating items list" still remains. I don't know if a screencast can catch it but it is very obvious. I must believe it doesn't happen in your system if you don't see it. I am already propared to test the original QT lib from Nokia (in case OpenSuse has tweaked it) and test a different window manager. It just feels strange because my system has no other problems related to drawing.

Just try to create pure qt pascal app (without LCL) , using qt45.pas only, so you'll see imediatelly does it flicks or not.Maybe I don't see flickering because my machine is too fast.

zeljko

Reply by email

Juha Manninen
to zeljko

Hi,

There's "big" difference between my devel system and yours :) 1.My system is glibc 2.3.4 based (fedora 3) with few dozen pacakges created

by me (eg. kernel is 2.6.26)

I have glibc 2.10.1.

2.XOrg is 6.8.2 and there's BIG diff between XOrg < 7.0 and >= 7.0

Here X.Org X Server 1.6.5
... whatever that means. I think it is > 7.0.

3.My qt version is 4.5.3 but compiled (and packaged) by me with -no-sse

since it segfaults imediatelly on glibc < 2.4 because of glibc 2.3.XX bugs.

4.I've tested 4.6.GIT yesterday and it works ok.

QT 4.6.2 here.

5.Bindings are ok :)

Right. XOrg server is now the main suspect.

Cursor problem wasn't visible to me since my XOrg is 6.8.2 and I have pretty fast machine.

Fast machine didn't help there because the cursor stayed invisible until I moved it. Did you finally reproduce it or could you fix it without seeing the problem? I am still wondering...

Just try to create pure qt pascal app (without LCL) , using qt45.pas only, so you'll see imediatelly does it flicks or not. Maybe I don't see flickering because my machine is too fast.

Where do I put the QT combobox if there is no LCL form? There must be some container, right?

Juha

P.S.
Funny, I don't see my original message in Lazarus-QT list. Maybe it pops up there later.

Reply by email

zeljko
to Juha Manninen
Juha Manninen wrote 6 lines
> Cursor problem wasn't visible to me since my XOrg is 6.8.2 and I have > pretty fast machine. Fast machine didn't help there because the cursor stayed invisible until I moved it. Did you finally reproduce it or could you fix it without seeing the problem? I am still wondering...

I've fixed it without seeing the problem :)

Show quoted text 6 lines
> Just try to create pure qt pascal app (without LCL) , using qt45.pas > only, so you'll see imediatelly does it flicks or not. Maybe I don't see > flickering because my machine is too fast. Where do I put the QT combobox if there is no LCL form? There must be some container, right?

Here is example how to create non LCL app (I don't know if it works, I've used it to test some things some time ago, probably you have to change hooks because this is pretty old example).

program testforjuha;
{$mode objfpc}{$H+}
uses

  {$IFDEF UNIX}
  cthreads,
  clocale,
  cwstring,
  {$ENDIF}
  Classes,
  SysUtils,
  { you can add units after this }
  qt4;

type TApp = class (TObject)

  public
    qApp: QApplicationH;
    qWin: QMainWindowH;
    qPro: QProgressBarH;
    qEdit: QLineEditH;
    qEdit2: QLineEditH;
    qCombo: QComboBoxH;
    FDropList: QListWidgetH;
    qStatus: QStatusBarH;
    qLabel1: QLabelH;
    qLabel2: QLabelH;
    qLabel3: QLabelH;
    qPrn: QPrinterH;
    FAppEvenFilterHook: QObject_hookH;
    FProgresEvenFilterHook: QObject_hookH;
    FComboEventFilterHook: QObject_hookH;
    FEditEventFilterHook: QObject_hookH;
    FSelectHook: QComboBox_hookH;
    FSelectionChangeHook: QListWidget_hookH;
    FItemPressedHook: QListWidget_hookH;
    constructor Create;
    destructor Destroy; override;
    function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
    function ProgresEventFilter(Sender: QObjectH; Event: QEventH): Boolean;
cdecl;
    procedure SlotSelect(index: Integer); cdecl;
    procedure signalSelectionChanged(); cdecl;
    procedure signalItemActivated(Item: QListWidgetItemH); cdecl;
    function Execute: Integer;
  end;
procedure TApp.SlotSelect(index: Integer); cdecl;
begin
  writeln('Slot select from comboBox ....');
end;
procedure TApp.signalSelectionChanged(); cdecl;
var
  Item: QListWidgetItemH;
  List: QListWidgetH;
  i: Integer;
begin
  WriteLn('QComboBox ListWidget signalSelectionChange');
  List := QListWidgetH(QComboBox_view(qCombo));
  Item := QListWidget_currentItem(List);
  if Item  nil then
  begin
    writeln('ITEM SELECTED ? ',QListWidgetItem_isSelected(Item));
    i := QListWidget_row(List, Item);
    if QListWidgetItem_isSelected(Item) then
    begin
      QComboBox_setCurrentIndex(qCombo, i);
    end;
    writeln('CHANGED ROW=',i);
  end;
end;
procedure TApp.signalItemActivated(Item: QListWidgetItemH); cdecl;
var
  i: Integer;
  List: QListWidgetH;
begin
  writeln('QListWidget signalItemActivated() ');
  if Item = nil then
  begin
    writeln('******** ITEM IS NIL *********');
    exit;
  end;
  List := QListWidgetH(QComboBox_view(qCombo));
  i := QListWidget_row(List, Item);
  writeln('SignalItemActivated i=',i,'
Selected? ',QListWidgetItem_isSelected(Item));
end;
constructor TApp.Create;
var
  WStr: WideString;
begin
  inherited Create;
  qPrn := nil;
  qApp := QApplication_create(@argc, argv);
  FAppEvenFilterHook := QObject_hook_create(qApp);
  QObject_hook_hook_events(FAppEvenFilterHook, @EventFilter);
  qWin := QMainWindow_create();
  qStatus := QStatusBar_create();
  WStr := 'Label 1';
  qLabel1 := QLabel_create(@WStr);
  WStr := 'Label 2';
  qLabel2 := QLabel_create(@WStr);
  WStr := 'Label 3';
  qLabel3 := QLabel_create(@WStr);
  QStatusBar_addWidget(qStatus, qLabel1, 0);
  QStatusBar_addWidget(qStatus, qLabel2, 0);
  QStatusBar_addWidget(qStatus, qLabel3, 1);
  QMainWindow_setStatusBar(qWin, qStatus);
  QWidget_resize(qWin, 800, 600);
  qPro := QProgressBar_create(qWin);
  qEdit := QLineEdit_create(qWin);
  qEdit2 := QLineEdit_create(qWin);
  qCombo := QComboBox_create(qWin);
  // QWidget_setMouseTracking(qCombo, True);
  // QWidget_setFocusPolicy(qCombo, QtStrongFocus);
  // QWidget_setAttribute(qCombo, QtWA_MacShowFocusRect, True);
  // QWidget_setAttribute(qCombo, QtWA_KeyboardFocusChange, True);
  FSelectHook := QComboBox_hook_create(qCombo);
  QComboBox_hook_hook_currentIndexChanged(FSelectHook, @SlotSelect);
  FDropList := QListWidget_create();
  QAbstractItemView_setAutoScroll(FDropList, True);
  QComboBox_setModel(qCombo, QAbstractItemView_model(FDropList));
  QComboBox_setView(qCombo, FDropList);
  FSelectionChangeHook := QListWidget_hook_create(FDropList);
  QListWidget_hook_hook_itemSelectionChanged(FSelectionChangeHook,
@signalSelectionChanged);
  FItemPressedHook := QListWidget_hook_create(FDropList);
  QListWidget_hook_hook_itemActivated(FItemPressedHook, @signalItemActivated);
  FProgresEvenFilterHook := QObject_hook_create(qPro);
  QObject_hook_hook_events(FProgresEvenFilterHook, @ProgresEventFilter);
  FComboEventFilterHook := QObject_hook_create(qCombo);
  QObject_hook_hook_events(FComboEventFilterHook, @ProgresEventFilter);
  FEditEventFilterHook := QObject_hook_create(qEdit2);
  QObject_hook_hook_events(FEditEventFilterHook, @ProgresEventFilter);
  // QComboBox_setEditable(qCombo, True);
  WStr := 'One';
  QComboBox_addItem(qCombo, @WStr, QVariant_create());
  WStr := 'Two';
  QComboBox_addItem(qCombo, @WStr, QVariant_create());
  WStr := 'Three';
  QComboBox_addItem(qCombo, @WStr, QVariant_create());
  WStr := 'Four';
  QComboBox_addItem(qCombo, @WStr, QVariant_create());
  WStr := 'Five';
  QComboBox_addItem(qCombo, @WStr, QVariant_create());
  WStr := 'Six';
  QComboBox_addItem(qCombo, @WStr, QVariant_create());
  WStr := 'Seven';
  QComboBox_addItem(qCombo, @WStr, QVariant_create());
  WStr := 'Eight';
  QComboBox_addItem(qCombo, @WStr, QVariant_create());
  WStr := 'Nine';
  QComboBox_addItem(qCombo, @WStr, QVariant_create());
  WStr := 'Eleven';
  QComboBox_addItem(qCombo, @WStr, QVariant_create());
  WStr := 'Twelve';
  QComboBox_addItem(qCombo, @WStr, QVariant_create());
  WStr := 'Thirteen';
  QComboBox_addItem(qCombo, @WStr, QVariant_create());
  WStr := 'Fourteen';
  QComboBox_addItem(qCombo, @WStr, QVariant_create());
  WStr := 'Fifteen';
  QComboBox_addItem(qCombo, @WStr, QVariant_create());
  WStr := 'Sixteen';
  QComboBox_addItem(qCombo, @WStr, QVariant_create());
  WStr := 'Seventeen';
  QComboBox_addItem(qCombo, @WStr, QVariant_create());
  WStr := 'Eighteen';
  QComboBox_addItem(qCombo, @WStr, QVariant_create());
  WStr := 'Nineteen';
  QComboBox_addItem(qCombo, @WStr, QVariant_create());
  WStr := 'Twenty';
  QComboBox_addItem(qCombo, @WStr, QVariant_create());
  WStr := 'Twenty one';
  QComboBox_addItem(qCombo, @WStr, QVariant_create());
  WStr := 'Twenty two';
  QComboBox_addItem(qCombo, @WStr, QVariant_create());
  // QWidget_setFocusPolicy(qCombo, QtStrongFocus);
  // QWidget_setFocusPolicy(qCombo, QtClickFocus);
  QWidget_setFocusPolicy(qPro, QtNoFocus);
  QWidget_setMouseTracking(qPro, True);
  QWidget_resize(qPro, 500, 30);
  QWidget_move(qPro, 20, 100);
  QProgressBar_setValue(qPro, 40);
  QLineEdit_setFrame(qEdit, False);
  QLineEdit_setFrame(qEdit2, False);
  QWidget_move(qEdit, 20, 160);
  QWidget_move(qEdit2, 200, 160);
  QWidget_setEnabled(qEdit, False);
  //QComboBox_setEditable(qCombo , True);
  QWidget_move(qCombo, 320, 160);
  QWIdget_show(qWin);
  // QWidget_showMaximized(qWin);
end;
destructor TApp.Destroy;
begin
  QListWidget_hook_destroy(FItemPressedHook);
  QListWidget_hook_destroy(FSelectionChangeHook);
  QComboBox_hook_destroy(FSelectHook);
  QObject_hook_destroy(FEditEventFilterHook);
  QObject_hook_destroy(FComboEventFilterHook);
  QObject_hook_destroy(FProgresEvenFilterHook);
  if qPrn  nil then
    QPrinter_destroy(qPrn);
  inherited Destroy;
end;
function TApp.Execute: Integer;
begin
  Result := QApplication_exec();
end;
function TApp.EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
begin
  Result := False;
  QEvent_accept(Event);
  (*
  case QEvent_type(Event) of
    QEventMouseButtonPress: writeln('Mouse press ....');
    QEventMouseButtonRelease: writeln('Mouse release  ....');
    QEventMouseButtonDblClick: writeln('Mouse dbl click ....');
  end;
  *)
end;
function TApp.ProgresEventFilter(Sender: QObjectH; Event: QEventH): Boolean;
cdecl;
var
  Ev: QKeyEventH;
  Modifiers: QtKeyboardModifiers;
  Text: WideString;
  Key: Integer;
  NKey: Integer;
  KScan: LongWord;
  i: Integer;
  AKey: Char;
  Opt: QStyleOptionComboBoxH;
  AState: QStyleState;
  WTitle: WideString;
  WStr: WideString;
  s: String;
begin
  Result := False;
  QEvent_accept(Event);
  case QEvent_type(Event) of
    QEventFocusIn:
    begin
      writeln('COMBO IS FOCUSED !');
    end;
    QEventMouseButtonPress:
    begin
      // QWidget_setEnabled(qEdit, true);
      // QWidget_update(qEdit);
      writeln('Progres Mouse press ....');
    end;
    QEventMouseButtonRelease: writeln('Progres Mouse release  ....');
    QEventMouseButtonDblClick: writeln('Progres Mouse dbl click ....');
    QEventKeyPress:
    begin
      Ev := QKeyEventH(Event);
      Modifiers := QKeyEvent_modifiers(Ev);
      Key := QKeyEvent_key(Ev);
      QKeyEvent_text(Ev, @Text);
      NKey := QKeyEvent_nativeVirtualKey(Ev);
      KScan := QKeyEvent_nativeScanCode(Ev);
    end;
    QEventKeyRelease:
    begin
    end;
  end;
end;
var
  FApp: TApp;
begin
  FApp := TApp.Create;
  FApp.Execute;
  FApp.Free;
end.

Reply by email

Juha Manninen
to zeljko

Hi,

Your program worked after adding "lcl/interfaces/qt" to project paths! Now I try to understand the code. I reorganized it so that all combobox related commands are together. So, you need this much code to just create a combobox:

///
  qCombo := QComboBox_create(qWin);
  FSelectHook := QComboBox_hook_create(qCombo);
  QComboBox_hook_hook_currentIndexChanged(FSelectHook, @SlotSelect);
  FDropList := QListWidget_create();
  QAbstractItemView_setAutoScroll(FDropList, True);
  QComboBox_setModel(qCombo, QAbstractItemView_model(FDropList));
  QComboBox_setView(qCombo, FDropList);
  FSelectionChangeHook := QListWidget_hook_create(FDropList);
  QListWidget_hook_hook_itemSelectionChanged(FSelectionChangeHook, at signalSelectionChanged);
  FItemPressedHook := QListWidget_hook_create(FDropList);
  QListWidget_hook_hook_itemActivated(FItemPressedHook, @signalItemActivated);
  FComboEventFilterHook := QObject_hook_create(qCombo);
  QObject_hook_hook_events(FComboEventFilterHook, @ProgresEventFilter);
  FillCombo(qCombo);
  QWidget_move(qCombo, 320, 160);
///

FillCombo() is an extracted function that adds items to list with QComboBox_addItem().

Why do you need to create FDropList separately? Doesn't QT combobox provide its own list? I guess in real (C++) QT program you don't need to do that. I haven't really programmed with QT but I have compiled some programs and the code looks compact and clear (considering it is C++).

Then I found :
  function TApp.ProgresEventFilter(Sender: QObjectH; Event: QEventH): Boolean;

I added FillCombo() there like this:

  case QEvent_type(Event) of
    QEventFocusIn:
    begin
      writeln('COMBO IS FOCUSED !');
      FillCombo(qCombo);
    end;

I really don't understand how it knows that the combobox gets focus and not some other control, but somehow it works.
Now more items get added to the combo-list every time it gets focus. (I didn't clear the old ones but for this test it is OK.)
No flicker! It works like any other QT application, smoothly and nicely. I will not change my QT version or window manager after all. The problem is somewhere else.

One important note: this combobox is fundamentally different from LCL combobox. The LCL version has an edit control, the QT version in this demo program does not. My problem is exactly in the edit control drawing. How to create a similar combobox with edit control?

Regards,
Juha

Reply by email

zeljko
to Juha Manninen
Juha Manninen wrote
Why do you need to create FDropList separately? Doesn't QT combobox provide its own list? I guess in real (C++) QT program you don't need to do that. I haven't really programmed with QT but I have compiled some programs and the code looks compact and clear (considering it is C++).

I told you that it's my test case for something (don't know what purpose), so change code according your needs. No, you don't need separate FDropList. You can reach items from QComboBox_view() abstract item view (which is QListWidget afaik).

Show quoted text 16 lines
Then I found : function TApp.ProgresEventFilter(Sender: QObjectH; Event: QEventH): Boolean; I added FillCombo() there like this: case QEvent_type(Event) of QEventFocusIn: begin writeln('COMBO IS FOCUSED !'); FillCombo(qCombo); end; I really don't understand how it knows that the combobox gets focus and not some other control, but somehow it works.

just because progresEventFilter() hook is attached to combo box and not to other controls , as i can see from my example only qCombo and one line edit should trigger, but progressbar not since it's focuspolicy=QtNoFocus .

Show quoted text 10 lines
Now more items get added to the combo-list every time it gets focus. (I didn't clear the old ones but for this test it is OK.) No flicker! It works like any other QT application, smoothly and nicely. I will not change my QT version or window manager after all. The problem is somewhere else. One important note: this combobox is fundamentally different from LCL combobox. The LCL version has an edit control, the QT version in this demo program does not. My problem is exactly in the edit control drawing. How to create a similar combobox with edit control?
QComboBox_setEditable(qCombo, True);

Reply by email

Juha Manninen
to zeljko
I told you that it's my test case for something (don't know what purpose), so change code according your needs. No, you don't need separate FDropList. You can reach items from QComboBox_view() abstract item view (which is QListWidget afaik).

Right, but your LCL binding code also has a separate FDropList. Actually I was thinking of that when I asked my question.

function TQtComboBox.GetDropList: TQtListWidget;
begin
  if FDropList = nil then
  begin
    FDropList := TQtListWidget.CreateFrom(LCLObject, QListWidget_create());
    FDropList.setAttribute(QtWA_NoMousePropagation, False);
    FDropList.OwnerDrawn := OwnerDrawn;
    QComboBox_setModel(QComboBoxH(Widget), FDropList.getModel);
    QComboBox_setView(QComboBoxH(Widget), QListWidgetH(FDropList.Widget));
  end;
  Result := FDropList;
end;

However, it seems to work in the qt only pascal app without blinking so is was not the problem.
But, now I found a big (?) difference:

    FLineEdit: TQtLineEdit;
    FDropList: TQtListWidget;

So, there is not only a separate DropList but also a separate LineEdit ! Your qt only pascal app doesn't have it.
I feel we are nearing the essence of the problem... :-)

Why are those sub-controls separated if the QT control already provides them built-in? I ask it because I don't know the code well. I am ready to experiment with the LCL bindings code but I guess you have already tried the obvious solutions and there was a problem and then you ended up with the current solution.

There is also a variable:

    FDropListVisibleInternal: Boolean;

which (I guess) means you were testing with both built-in and internal DropLists.

QComboBox_setEditable(qCombo, True);

Ok, right, it was so easy. It didn't change the behaviour though. Still no flicker.

Regards,
Juha

Reply by email

zeljko
to Juha Manninen
Juha Manninen wrote 31 lines
> I told you that it's my test case for something (don't know what > purpose), so change code according your needs. No, you don't need > separate FDropList. You can reach items from QComboBox_view() abstract > item view (which is QListWidget afaik). Right, but your LCL binding code also has a separate FDropList. Actually I was thinking of that when I asked my question. function TQtComboBox.GetDropList: TQtListWidget; begin if FDropList = nil then begin FDropList := TQtListWidget.CreateFrom(LCLObject, QListWidget_create()); FDropList.setAttribute(QtWA_NoMousePropagation, False); FDropList.OwnerDrawn := OwnerDrawn; QComboBox_setModel(QComboBoxH(Widget), FDropList.getModel); QComboBox_setView(QComboBoxH(Widget), QListWidgetH(FDropList.Widget)); end; Result := FDropList; end; However, it seems to work in the qt only pascal app without blinking so is was not the problem. But, now I found a big (?) difference: FLineEdit: TQtLineEdit; FDropList: TQtListWidget; So, there is not only a separate DropList but also a separate LineEdit ! Your qt only pascal app doesn't have it. I feel we are nearing the essence of the problem... :-)

FLineEdit & FDropList are implemented because of:
1.Controlling autocompletion by LCL
2.Controlling selection length (selstart,selstop) by LCL 3.Allow owner draw for combo box (without FDropList it's impossible). etc etc
So, it must be like that and it won't be changed, since qtlcl combobox will be almost unuseable with lcl (many properties will not work).

Show quoted text 10 lines
Why are those sub-controls separated if the QT control already provides them built-in? I ask it because I don't know the code well. I am ready to experiment with the LCL bindings code but I guess you have already tried the obvious solutions and there was a problem and then you ended up with the current solution. There is also a variable: FDropListVisibleInternal: Boolean; which (I guess) means you were testing with both built-in and internal DropLists.

No, it's there to avoid IntfGetItems() call if list is visible.

zeljko

Reply by email

zeljko
to Juha Manninen: Right, but your LCL binding code also has a separate FDropList. Actually I was thinking…
Juha Manninen wrote
I feel we are nearing the essence of the problem... :-)
I think that only problem could be TQtListWidget signals, you can test it by
adding check in:
procedure TQtListWidget.signalItemTextChanged(ANewText: PWideString); cdecl;
var
  Msg: TLMessage;
begin
  {$ifdef VerboseQt}
    WriteLn('TQtListWidget.signalItemTextChanged');
  {$endif}
  FillChar(Msg, SizeOf(Msg), #0);
  Msg.Msg := CM_TEXTCHANGED;
  if getVisible then	 <--------------- HERE
    DeliverMessage(Msg);
end;
and probably in other TQtListWidget signals
procedure TQtListWidget.signalSelectionChanged(); cdecl;
procedure TQtListWidget.signalCurrentItemChange(current: QListWidgetItemH;
  previous: QListWidgetItemH); cdecl;

Probably CM_TEXTCHANGED triggers LCL to update combobox editor. Can you test it and send feedback ?

zeljko

Reply by email

zeljko
to Juha Manninen: Right, but your LCL binding code also has a separate FDropList. Actually I was thinking…

On Friday 05 March 2010 15:49, Juha Manninen wrote: Edit !

Your qt only pascal app doesn't have it. I feel we are nearing the essence of the problem... :-)

no, seem that FDropList doesn't attach signals, but FLineEdit do that, so you can test

procedure TQtLineEdit.SignalTextChanged(p1: PWideString); cdecl;
var
  Msg: TLMessage;
begin
  FillChar(Msg, SizeOf(Msg), #0);
  Msg.Msg := CM_TEXTCHANGED;
  DeliverMessage(Msg); <---- comment this and see if it still flickers
end;

zeljko

Reply by email

Juha Manninen
to zeljko

Hi,

Show quoted text 12 lines
no, seem that FDropList doesn't attach signals, but FLineEdit do that, so you can test procedure TQtLineEdit.SignalTextChanged(p1: PWideString); cdecl; var Msg: TLMessage; begin FillChar(Msg, SizeOf(Msg), #0); Msg.Msg := CM_TEXTCHANGED; DeliverMessage(Msg); <---- comment this and see if it still flickers end;

Well, this fix looked so good that I was sure it works but no... The same flicker is still there.
I also tried the earlier changes but no difference. I will debug the code some more. I am quite sure it is related to the edit control. I just don't know this code well and have to guess a lot.

Juha

Reply by email

zeljko
to Juha Manninen
Juha Manninen wrote 5 lines
Well, this fix looked so good that I was sure it works but no... The same flicker is still there. I also tried the earlier changes but no difference. I will debug the code some more. I am quite sure it is related to the edit control. I just don't know this code well and have to guess a lot.

LCL is probably doing something, but also there could be some kind of loop between qt signals and LCL, nothing specially comes to my mind except things I mentioned before.
Maybe it would be best solution to disable all signals of TQtComboBox and TQtLineEdit and then see if there's flick.

You are inserting new item to combo items (using append() which calls add() which calls TQtComboBox.insertItem(), which is rounded by BeginUpdate() EndUpdate(), so in this case TQtComboBox signals should be blocked by statement "if InUpdate then exit;" inside signals procs. It is possible that some of signals is delayed (from qt side) so it triggers eg:
Combo.BeginUpdate();
Combo.InsertItem();
Combo.EndUpdate();
<----- signal triggers here and sends msg to LCL , so it creates unneeded traffic between lcl and qt.

zeljko

Reply by email

zeljko
to Juha Manninen: Well, this fix looked so good that I was sure it works but no... The same flicker is…
Juha Manninen wrote 20 lines
Hi, > no, seem that FDropList doesn't attach signals, but FLineEdit do that, so > you can test > > procedure TQtLineEdit.SignalTextChanged(p1: PWideString); cdecl; > var > Msg: TLMessage; > begin > FillChar(Msg, SizeOf(Msg), #0); > Msg.Msg := CM_TEXTCHANGED; > > DeliverMessage(Msg); <---- comment this and see if it still flickers > end; Well, this fix looked so good that I was sure it works but no... The same flicker is still there. I also tried the earlier changes but no difference. I will debug the code some more. I am quite sure it is related to the edit control. I just don't know this code well and have to guess a lot.

Even with this change in your example there's no flicking on my machine

procedure TForm1.FillItems(Num: integer);
var
  s: String;
  i: integer;
begin
  s:=IntToStr(Num);
  sl.Clear;
  sl.Append('First item'+s);
  sl.Append('Other one'+s);
  sl.Append('And more'+s);
  sl.Append('Final'+s);
  for i := 0 to 5000 do  // ADD MORE ITEMS TO SEE FLICK ... BUT NO FLICKING
    sl.Append('Item '+IntToStr(i));
end;

Reply by email

Juha Manninen
to zeljko: LCL is probably doing something, but also there could be some kind of loop between qt…

I found one minor thing from the code when debugging.

procedure TQtComboBox.setEditable(const AValue: Boolean);
begin
  QComboBox_setEditable(QComboBoxH(Widget), AValue);
  if not AValue then
    FreeAndNil(FLineEdit)
  else
  begin
    LineEdit.setFocusPolicy(getFocusPolicy);
    setText(FText);
  end;
//  if AValue then
//    setText(FText);
end;

The last commented lines can be removed.

I didn't find the actual problem I was looking for. I noticed however that the problem happens AFTER assigning stringlist to combobox items, not during the assignment.
There is a complicated set of messages as you suggested and they are very difficult to debug.

Maybe it would be best solution to disable all signals of TQtComboBox and TQtLineEdit and then see if there's flick.

I don't know how to disable them and now my brain capacity is used for today. I may return to this later but I may also wait until you have new versions of everything and you experience this problem, too. :-)

I even set breakpoints to
TQtLineEdit.getText and TQtLineEdit.setText
but they were not triggered. I don't know what is happening there, it may not be the edit control after all.

Regards,
Juha

Reply by email