You should read some books about C++ basics I think...
And QPointer behaves in the same way as normal pointer, so getting back to one of the first lessons about C++ and pointers you will see that:
1. If you want to reference the member of the object you use '.' operator:
SomeClass obj;
obj.someMemberFunction();
SomeClass obj;
obj.someMemberFunction();
To copy to clipboard, switch view to plain text mode
2. But if you want to reference the member of the object, but you have only the pointer to that object, you have to use '->' operator:
SomeClass *obj = new SomeClass;
obj->someMemberFunction();
SomeClass *obj = new SomeClass;
obj->someMemberFunction();
To copy to clipboard, switch view to plain text mode
And a QPointer<SomeClass> behaves exactly in same way as SomeClass * so you have to use -> operator to get the members from object pointed by a QPointer.
But you are trying to do very weird things, which are not even supposed to work:
HTMLWindow(WindowList.at(n));
HTMLWindow(WindowList.at(n));
To copy to clipboard, switch view to plain text mode
You are storing QPointer<HTMLWindow> in your list so:
WindowList.at(n)
WindowList.at(n)
To copy to clipboard, switch view to plain text mode
returns a QPointer that points to some object of HTMLWindow class, and it can be used like normal pointer, so the line:
HTMLWindow(WindowList.at(n));
HTMLWindow(WindowList.at(n));
To copy to clipboard, switch view to plain text mode
creates a new HTMLWindow object on a stack (a local variable in other words) with a existing HTMLWindow on index 'n' in your list as a parent because in that case the:
WindowList.at(n)
WindowList.at(n)
To copy to clipboard, switch view to plain text mode
is casted to QWidget *, if constructor of the HTMLWindow looks like :
HTMLWindow(QWidget *parent);
To copy to clipboard, switch view to plain text mode
And what you are trying to do is to cast the pointer to an object to instance of that object which obviously should fail, because how do you think the 32-bit (or more) integer value which the memory address of the object can be casted to that object, the whole HTMLWindow???
The next thing is that (as I said before) if this:
WindowList.at(0);
WindowList.at(0);
To copy to clipboard, switch view to plain text mode
returns the first element of your list, which is of type QPointer, doing like this:
WindowList.
at(0).
setGeometry(QRect(100,
100,
285,
110));
WindowList.at(0).setGeometry(QRect(100,100,285,110));
To copy to clipboard, switch view to plain text mode
is trying to use the setGeometry() method of a QPointer object, which, as I suppose, does not have the setGeometry() method. If you want to use the setGeometry() of the HTMLWindow oobject pointed by this QPointer you have to use '->' operator:
WindowList.
at(0)->setGeometry
(QRect(100,
100,
285,
110));
WindowList.at(0)->setGeometry(QRect(100,100,285,110));
To copy to clipboard, switch view to plain text mode
So, first of all, it is C++, not Delphi, so maybe you should find some time to learn some C++ basics before you start coding with it...
Bookmarks