OmixVisualization / qtjambi

QtJambi is a wrapper for using Qt in Java.
http://www.qtjambi.io
Other
365 stars 43 forks source link

[BUG] why setModel method is deprecated? #161

Closed long76 closed 1 year ago

long76 commented 1 year ago

Describe the bug io.qt.widgets.QTableWidget.setModel(QAbstractItemModel) io.qt.widgets.QTreeWidget.setModel(QAbstractItemModel) io.qt.widgets.QListWidget.setModel(QAbstractItemModel)

To Reproduce Steps to reproduce the behavior:

  1. create QTableWidget
  2. call setModel
  3. See warning

Expected behavior no deprecated warning

Screenshots If applicable, add screenshots to help explain your problem.

System (please complete the following information):

Additional context https://doc.qtjambi.io/5/deprecated-list.html https://doc.qtjambi.io/6/deprecated-list.html

omix commented 1 year ago

That's not a bug but the only way to represent a private overridden method in Java. Look at Qt's QTableWidget. Its setModel(QAbstractItemModel*) method is private. When calling it virtually it leads to assertion: Q_ASSERT(!"QTableWidget::setModel() - Changing the model of the QTableWidget is not allowed.");

As it is not possible to override a Java method with a private method, QtJambi makes them deprecated. When calling such a method anyway you earn a QNoImplementationException exception.

long76 commented 1 year ago

@omix thanks you can add it to javadoc?

omix commented 1 year ago

Yes, I'll do.