Delegate not working as expected...



  • I have implemented a delegate for a QTableView. The objective is to add a QIntValidator to one editor and a QDoubleValidator to another. In both cases the validator isn't working:

    @if( index.column() == _model->qtyNo())
    {
    QLineEdit *le = new QLineEdit(parent);
    le->setFrame(le->style()->styleHint(QStyle::SH_ItemView_DrawDelegateFrame, 0, le));
    le->setValidator (new QIntValidator(1, 999, le));
    return le;
    }
    else if( index.column() == _model->priceNo())
    {
    QLineEdit *le = new QLineEdit(parent);
    le->setFrame(le->style()->styleHint(QStyle::SH_ItemView_DrawDelegateFrame, 0, le));
    le->setValidator (new QDoubleValidator(0.0, 999.99, 2, le));
    return le;
    }

    return QSqlRelationalDelegate::createEditor(parent, option, index);@



  • wired.. don't see anything wrong with the code.. Can you try to read the validator after you set it and see if you get the same thing back..



  • Did you debug it and check, whether the code was reached where you set the validators?
    The other thing is you have to react on the validators. So what does not work with them?


Log in to reply
 

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