Results 1 to 4 of 4

Thread: How to set Validator for individual cell in QTable

  1. #1
    Join Date
    Feb 2007
    Posts
    63
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default How to set Validator for individual cell in QTable

    Hi,
    i want to set validator for Individual cells in a Qtable.

    I tried using setValidator function() but using it gave an error.


    How can i set validator for cell so that it can take only "T" & "R" as input.

    thanks

    regards
    Raghvendra

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to set Validator for individual cell in QTable

    I think you can reimplement this method
    http://doc.trolltech.com/3.3/qtablei...l#createEditor, e.g. create QLineEdit and set needed validator and then return it.

  3. #3
    Join Date
    Feb 2007
    Posts
    63
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: How to set Validator for individual cell in QTable

    Since the default editor type is QLine Edit for a QTable i used the following code
    to implement the validator for a QTable

    Qt Code:
    1. QRegExp rx( "(T|R|X|N)" );
    2. QValidator* validator = new QRegExpValidator( rx, this );
    3. QLineEdit *t = new QLineEdit(table1->viewport());
    4. t->setValidator(validator);
    To copy to clipboard, switch view to plain text mode 
    But this also didn't solved the problem.

    Plz tell me where is the problem.

    Regards

    Raghvendra
    Last edited by jpn; 13th September 2008 at 15:49. Reason: missing [code] tags

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to set Validator for individual cell in QTable

    Where did you place that piece of code? Inside the function proposed by spirit or somewhere else?
    J-P Nurmi

Similar Threads

  1. QTable, Removing cell focus
    By Kubil in forum Qt Programming
    Replies: 2
    Last Post: 27th July 2007, 10:13
  2. Highlighting a cell in QTable
    By sumsin in forum Qt Programming
    Replies: 1
    Last Post: 18th April 2007, 06:28
  3. word wrapping in QTable Cell
    By joseph in forum General Discussion
    Replies: 0
    Last Post: 27th November 2006, 09:30
  4. QTable - Cell Thickness
    By Solarity in forum Newbie
    Replies: 4
    Last Post: 16th March 2006, 19:15
  5. Qtable and Cell overflow
    By taylor34 in forum Qt Programming
    Replies: 1
    Last Post: 23rd February 2006, 09:23

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.