[Qt] QT binding anomalies
Juha Manninen
juha.manninen at phnet.fi
Fri Mar 5 12:27:02 CET 2010
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
More information about the Qt
mailing list