[Kde-bindings] Qyoto Crash when clicking an item in QListWidget

Arno Rehn arno at arnorehn.de
Thu Feb 28 16:08:31 UTC 2008


Am Dienstag 26 Februar 2008 19:48:39 schrieb William Lahti:
> The problem is when you have a QListWidget/View in a QDialog, then
> fill it and call Exec... it will crash when you click the item. Here's
> the testcase
Just looked over it - the problem isn't with QDialog, but with QListWidget. 
You are not allowed to call setModel on a QListWidget: here you should use 
addItem(). If you want to use a model and a view, use QListView with an 
QStandardItemModel or similar.
In C++ you get this error when you try to call QListWidget::setRow():

/opt/qt4.4/include/QtGui/qlistwidget.h: In function 'int main(int, char**)':
/opt/qt4.4/include/QtGui/qlistwidget.h:293: error: 'virtual void 
QListWidget::setModel(QAbstractItemModel*)' is private
test.cpp:21: error: within this context

However it's not possible in C# to change the access type of a 
function/field/property in a subclass again. So simply don't use 
QListWidget::setModel(). Use a QListView and the whole thing will be fine.

-- 
Arno Rehn
arno at arnorehn.de



More information about the Kde-bindings mailing list