Results 1 to 12 of 12

Thread: Is an error in doc whith QTableWidget::setModel?

  1. #1
    Join Date
    Sep 2008
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Is an error in doc whith QTableWidget::setModel?

    I wonder is the method QTableWidget::setModel reimplemented as a private? In Qt Reference Documentation it seems to be public?

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Is an error in doc whith QTableWidget::setModel?

    wha is version of Qt? I didn't find setModel as public in docs in 4.4.3.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Is an error in doc whith QTableWidget::setModel?

    what is version of Qt? I didn't find setModel as public in 4.4.3 docs.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Is an error in doc whith QTableWidget::setModel?

    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

  5. #5
    Join Date
    Oct 2007
    Location
    India
    Posts
    162
    Thanks
    20
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Is an error in doc whith QTableWidget::setModel?

    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.

  6. #6
    Join Date
    Sep 2008
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Is an error in doc whith QTableWidget::setModel?

    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!

  7. #7
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Is an error in doc whith QTableWidget::setModel?

    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.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Is an error in doc whith QTableWidget::setModel?

    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.

  9. #9
    Join Date
    Sep 2008
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Is an error in doc whith QTableWidget::setModel?

    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?

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Is an error in doc whith QTableWidget::setModel?

    Quote Originally Posted by mikolaj View Post
    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.

  11. #11
    Join Date
    Sep 2008
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Is an error in doc whith QTableWidget::setModel?

    But I think, it would be more comfortable if the method public in parent not available in children was mentioned in docs.

  12. #12
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Is an error in doc whith QTableWidget::setModel?

    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.

    ...
    J-P Nurmi

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.