[SOLVED] Show a QMessagebox with QItemDelegate



  • I have a QTableView with a model and an itemdelegate set.

    In some columns it may not be possible to change the data. So in my createEditor, I return NULL as editor.

    But now I want for those columns to return a MessageBox that tells the user that editing in this version is not possible.

    So when the column is clicked for editing, it has to return a messagebox.

    Is this in any way possible to create?

    Thanks in advance



  • I found a solution myself.

    You don't return a QMessageBox like this:
    @
    if(kResColRank == index.column())
    {
    QSpinBox *editor = new QSpinBox(parent);
    editor->setMinimum(0);
    editor->setMaximum(1000);
    editor->setSingleStep(1);
    return QMessageBox::information(parent, tr("TEXT"), tr("TEXT.\n"));
    }
    @

    But you just pop up the messagebox:
    @
    if(kResColRank == index.column())
    {
    QSpinBox *editor = new QSpinBox(parent);
    editor->setMinimum(0);
    editor->setMaximum(1000);
    editor->setSingleStep(1);
    QMessageBox::information(parent, tr("TEXT"), tr("TEXT.\n"));
    return NULL;
    }
    @

    Easy solution actually. But didn't know it.


Log in to reply
 

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