Important: Please read the Qt Code of Conduct -

Close editor when I click

  • I have a a delegate in a tableview.
    I created a new qtable view where i reimplemented mousepressevent. I need to close qcombobox when i clicked over the table view, outside the model. Any solutions?

    void mousePressEvent(QMouseEvent *event)
            if (event->button() == Qt::LeftButton)
                QModelIndex index = indexAt(event->pos());
                if ((index.flags() == (Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable)) &&
                        (index.isValid() == true))
                { // column you want to use for one click

  • Lifetime Qt Champion


    Wouldn't setEditTrigger with QAbstractItemView::CurrentChanged do what you want ?

Log in to reply