PDA

View Full Version : Is an error in doc whith QTableWidget::setModel?



mikolaj
1st January 2009, 22:38
I wonder is the method QTableWidget::setModel reimplemented as a private? In Qt Reference Documentation it seems to be public?

spirit
2nd January 2009, 06:38
wha is version of Qt? I didn't find setModel as public in docs in 4.4.3.

spirit
2nd January 2009, 06:39
what is version of Qt? I didn't find setModel as public in 4.4.3 docs.

aamer4yu
2nd January 2009, 07:54
I wonder is the method QTableWidget::setModel reimplemented as a private?

YES !
In docs, you are seeing QAbstractItemView::setModel .

QTableWidget manages its own internal model. If you want to use model, use it with QTableView :)

montylee
2nd January 2009, 08:18
yup, setModel() can be used only with item view classes like QListView, QTableView, QTreeView etc. For QTableWidget, you can't play with the model directly.

mikolaj
3rd January 2009, 15:00
QTableWidget manages its own internal model. If you want to use model, use it with QTableView

But it not result from docs. This method exists in list of inherited method.

Thanks!

aamer4yu
5th January 2009, 06:41
Well, you can refer in source code for QTableWidget.
And you are right, setModel shows in list of all methods for QTableWidget. May be its a mistake.

wysota
5th January 2009, 08:51
It is a method of the base class of QTableWidget so why shouldn't it be listed there? The documentation clearly says it's a list of all methods including inherited ones. It's just reimplemented as private so that you don't have a stupid idea of calling it and segfaulting your application on the first reference to the widget.

mikolaj
5th January 2009, 16:53
The documentation clearly says it's a list of all methods including inherited ones. Yes, but documentation shows only public method, and also should show inherited public method.

It's just reimplemented as private so Where it is written?


you don't have a stupid idea of calling it and segfaulting your application on the first reference to the widget. For you knowledge, you can't compile program where you use virtual method reimplemented as private!
And I have a favour to ask of you Can you be more polite?

wysota
5th January 2009, 20:07
Yes, but documentation shows only public method, and also should show inherited public method.
When you access the "all method" page, all methods are shown. When you access the base documentation page, only those declared in this particular class are mentioned. SetModel() is declared in the base class and specifically hidden in the subclass. As you see no private methods are mentioned in any docs.


Where it is written?

Here:
"If you want a table that uses your own data model you should use QTableView rather than this class."



For you knowledge, you can't compile program where you use virtual method reimplemented as private!
That's the whole idea of it being redeclared as private. If it remained public you could have compiled it and thus wrecked the application without any possiblility of knowing why and you would have blamed Qt code for it as the debugger would clearly indicate the crash was caused by Qt code and not yours.


And I have a favour to ask of you Can you be more polite?
Where have I been impolite? By using the word "stupid"? I don't think there is anything impolite there, I do stupid things as well, there is nothing wrong in making mistakes and calling ones actions such, especially if you learn from them. Please note I didn't call you stupid, I said the method is private to stop stupid ideas of using it where it is not appropriate. You can't imagine what people are trying to do with Qt code :) If your ideas felt offended by my words, I appologize to them.

mikolaj
6th January 2009, 21:44
But I think, it would be more comfortable if the method public in parent not available in children was mentioned in docs.

jpn
8th January 2009, 20:31
From QTableWidget docs, right from the beginning of the detailed description:


The QTableWidget class provides an item-based table view with a default model.

...

If you want a table that uses your own data model you should use QTableView rather than this class.

...