How does void QTableWidget::setItemPrototype ( const QTableWidgetItem * item ) clones objects?

QTableWidget::setItemPrototype says following.

"The table widget will use the item prototype clone function when it needs to create a new table item. For example when the user is editing in an empty cell. This is useful when you have a QTableWidgetItem subclass and want to make sure that QTableWidget creates instances of your subclass."

How does this actually work as you can pass any of the QTableWidgetItem subclass pointer to setItemPrototype and at run time there is no way you can get the size of an object having just pointer to it?


QTableWidgetItem::clone() is a virtual member function and has to be reimplemented by subclasses of QTableWidget. Thus, when clone() is called, the implementation of clone() in the subclass is getting invoked, and in the subclass, the correct type is of course known.

Need Your Help

OpenGL Draw only some indexes from vertex array

c++ opengl

how can I only draw selected indices from vertex array in OpenGL?