Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Delegate not working as expected...
Forum Updated to NodeBB v4.3 + New Features

Delegate not working as expected...

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    scarleton
    wrote on last edited by
    #1

    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);@

    1 Reply Last reply
    0
    • T Offline
      T Offline
      thisisbhaskar
      wrote on last edited by
      #2

      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..

      1 Reply Last reply
      0
      • G Offline
        G Offline
        giesbert
        wrote on last edited by
        #3

        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?

        Nokia Certified Qt Specialist.
        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved