Results 1 to 2 of 2

Thread: InputMask on QTreeWidgetItem

  1. #1
    Join Date
    Mar 2013
    Qt products

    Default InputMask on QTreeWidgetItem


    Is there any way to put an inputMask onto a QTreeWidgetItem that is listed as Qt::ItemIsEditable? I need to check to make sure that a value typed in is numeric. I know I can do this easily with a QLineEdit, but I don't know what kind of widget is created when you just create a default QTreeWidgetItem and set its text. I know that QTreeWidget has a method itemWidget() that returns a QWidget*, but I don't want to just cast it as a QLineEdit if it isn't one. I really want to be able to restrict what inputs the user can make.


  2. #2
    Join Date
    Jan 2006
    Graz, Austria
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Unix/X11 Windows

    Default Re: InputMask on QTreeWidgetItem

    You can try subclassing QTreeWidget item and implement the data method such that it returns a numerical value when the role is Qt::EditRole.

    Alternatively you could look into creating an item delegate for that column.


Similar Threads

  1. InputMask Problem
    By ehntun in forum Newbie
    Replies: 2
    Last Post: 23rd October 2012, 03:51
  2. QLineEdit inputMask and validator
    By vhptt in forum Newbie
    Replies: 3
    Last Post: 1st September 2012, 02:36
  3. Replies: 2
    Last Post: 25th November 2010, 06:00
  4. Replies: 10
    Last Post: 12th February 2009, 07:23
  5. Help on inputMask
    By vieraci in forum Newbie
    Replies: 6
    Last Post: 26th July 2007, 14:43

Tags for this Thread


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.