[solved] QTableView and edit mode



  • Hello,

    I have implemented a very simple Widget, let say
    @W::W(QAbstractItemModel * model)
    {

    *tv = new QTableView(this);
    tv.setModel(model); // case 1

    //setModel(model); // case 2
    }
    @
    and @class W : public QTableView
    {
    Q_OBJECT
    public:
    explicit W(QAbstractItemModel * model);

    QTableView * tv;
    }@
    actually in the case 1, the table is editable, in the second not.
    Can someone explain me what is the distinction between both ?



  • You can use "setEditTriggers(QAbstractItemView::AllEditTriggers)":http://qt-project.org/doc/qt-5.0/qtwidgets/qabstractitemview.html#editTriggers-prop for your tableView



  • H!i,

    Thanks for your reply.
    In fact when i use setEditTriggers(QAbstractItemView::DoubleClicked); it does not work as i would like ;
    and when i use setEditTriggers(QAbstractItemView::DoubleClicked) neither.
    However i don't see any real difference between the two cases showed in the first post, that's why ia am asking the question also.



  • Ok one simple question since W inherits from QTableView then what is the need of having another table TV initialized inside class W .


  • Moderators

    [quote author="dmcr" date="1370260449"]
    However i don't see any real difference between the two cases showed in the first post, that's why ia am asking the question also.[/quote]
    There is no semantic difference between those 2 cases (regarding the usage of setModel()). You must be doing something else after the constructor is called which prevents the second case to work as expected.
    Since case 1 works for you (which lets me assume that you don't set the model on itself) you maybe set another model afterwards which is not editable?



  • bq. There is no semantic difference between those 2 cases

    Yes that's what i intend to explain.
    Actually i had some mousePressEvent, whitch was changing th behaviour.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.