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
                    setCurrentIndex(index);
                    edit(index);
                }
            }
            QTableView::mousePressEvent(event);
        }
    

  • Lifetime Qt Champion

    Hi,

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


Log in to reply
 

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