????? ?????? wrote 18 lines
Hello, Items specific to the Qt widget set
Is it ok to write such contructions:
function TQtListWidget.IndexAt(APoint: PQtPoint): Integer;
var
AModelIndex: QModelIndexH;
begin
AModelIndex := QModelIndex_create();
QListView_indexAt(QListWidgetH(Widget), AModelIndex, APoint);
Result := QModelIndex_row(AModelIndex);
end;
I mean such will be better:
AModelIndex := QListView_indexAt(QListWidgetH(Widget), APoint);
Result := QModelIndex_row(AModelIndex);
Maybe I misunderstand something?
When a function result is a Qt Class without a "*" (so not a pointer to a class instance), you are not supposed to keep it around. In C++ you would immediately assign it (copy into) another c++ class instance. The c++ compiler knows how. The pascal compiler does not know how to copy an instance into another. The binding could return a pointer to the instance, but would the violate the c++ header. Therefore I chose to make all Qt Classes function results (without *), parameters instead, and let the c++ compiler do the copying inside the binding. You have to create an instance ofcourse.
C++:
void test {
QModelIndex model; // -> instantiate instance on stack model = SomeAbstractItemView->indexAt(somePoint); // c++ does the copying } // --> model get destroyed from stack by compiler
pascal:
procedure test;
begin
var model QModelIndexH;
model:=QModelIndex_create;// -> instantiate instance on stack
AbstractItemView_indexAt(SomeAbstractItemView,model,somePoint); // c++ does the copying in the binding.
QModelIndex_destroy(model); // you have to destroy manually
end;
I you prefer me not doing this, we can try to revert and see what happens. I am not sure this was necessary.
Show quoted text 6 lines