1

Considering the following QAbstractItemModel subclass:

class MyItemModel : public QAbstractItemModel {
Q_OBJECT
public:
    (...)
    virtual int rowCount(const QModelIndex& parentIdx = QModelIndex()) const override;
    (...)
};

And a simple QDockWidget for displaying a QTreeView

class DockWidget : public QDockWidget {
Q_OBJECT
public:
    DockWidget() {
         view = new QTreeView();
         setWidget(view);
    }
private:
    QTreeView *view;
}

If I call DockWidget constructor on Windows MyItemModel::rowCount() is being called. If I use this code on Linux, MyItemModel::rowCount() isn't being called. Is this correct?

I suspect that Qt for Windows has something that trigger rowCount() when QDockWidget::setWidget() is called and this is not necessary on Linux. But it is just a guess.

Qt version 4.8.3,
Windows 7 64 bits,
Ubuntu both 32 and 64bits

4

0 に答える 0