1

次のコードがあります。

proxy_index = self.log_list.filter_proxy_model.createIndex(index, COL_REV)
model_index = self.log_list.filter_proxy_model.mapToSource(proxy_index)
revno = self.log_list.model.data(model_index,QtCore.Qt.DisplayRole)
self.setEditText(revno.toString())

コードは 2 行目でクラッシュしました。例外は発生しません。トレースバックなし。警告はありません。これを修正するにはどうすればよいですか?

4

2 に答える 2

2

It may be that you're using the proxy model's createIndex() method incorrectly. Usually, the createIndex() method is called as part of a model's index() method implementation.

Have you tried calling the proxy model's index() method to get a proxy index then mapping that to the source?

Perhaps you could show the code in context or explain what you are trying to do.

于 2009-03-23T00:22:32.737 に答える
0

私は同じ問題に遭遇しましたが、幸いなことに、デイビッドが推奨するように createIndex () の代わりに index () メソッドを使用すると魔法が起こります。一般に、 index () メソッドの外で QModelIndex の内部ポインターをいじるのは悪い考えです。独自のモデルを使用している場合でも、Qts View コードはユーザーにとってかなりわかりにくいため、内部ポインターをいじると予期しない動作が発生することがよくあります。

于 2009-08-26T04:05:42.153 に答える