Results 1 to 3 of 3

Thread: InputMask or Validator for QTableWidgetItem

  1. #1
    Join Date
    Aug 2010
    Posts
    65
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default InputMask or Validator for QTableWidgetItem

    Is it possible to add an Input Mask or Validator to a QTableWidgetItem? Given how they don't inherit anything from anyone and there's nothing relevant in the documentation, I'm guessing not, but... I've been wrong before.

    Will I have to use a series of QLineEdit's to do the job?

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: InputMask or Validator for QTableWidgetItem

    That would typically be a job for a QItemDelegate or QStyledItemDelegate.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  3. #3
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: InputMask or Validator for QTableWidgetItem

    hi,
    im using this way to achive it.
    Qt Code:
    1. QWidget *mylineEditDelegate::createEditor(QWidget *parent,const QStyleOptionViewItem & option ,const QModelIndex &ind index ) const
    2. QLineEdit *editor = new QLineEdit(parent);
    3. editor->setValidator(new QRegExpValidator(QRegExp("\\d?"),editor));
    To copy to clipboard, switch view to plain text mode 

    hope it helps
    Bala

Similar Threads

  1. Focus problem with QLineEdit and InputMask
    By ttvo in forum Qt Programming
    Replies: 2
    Last Post: 26th May 2009, 13:57
  2. Replies: 10
    Last Post: 12th February 2009, 07:23
  3. Validator for QDoubleSpinBox
    By ehamberg in forum Qt Programming
    Replies: 3
    Last Post: 15th March 2008, 11:37
  4. QRegExp validator
    By mattia in forum Newbie
    Replies: 2
    Last Post: 28th November 2007, 08:15
  5. Help on inputMask
    By vieraci in forum Newbie
    Replies: 6
    Last Post: 26th July 2007, 14:43

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.