Results 1 to 2 of 2

Thread: InputMask on QTreeWidgetItem

  1. #1
    Join Date
    Mar 2013
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default InputMask on QTreeWidgetItem

    Hello,

    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.

    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    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.

    Cheers,
    _

Similar Threads

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

Tags for this Thread

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.