Results 1 to 2 of 2

Thread: How to set limits on the text entered in any cell of a QTableView?

  1. #1
    Join Date
    Apr 2011
    Posts
    5
    Qt products
    Qt4 Qt Jambi
    Platforms
    Windows

    Default How to set limits on the text entered in any cell of a QTableView?

    Hello,

    I'm trying to do a crossword game using QT. I'm using QTableView for this and It should be that the user can enter one and only one letter in any of the editable cells in the QTableView. The problem is that I cannot seem to figure out how to put limits or restrictions on what the user can enter in each editable cell. How to do it? I have looked at QT documentation, searched online, looked in key/mouse events in QT but still I did not get how to do it. Any help well be appreciated. Thank you.

  2. #2
    Join Date
    Jul 2010
    Location
    Indonesia
    Posts
    83
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: How to set limits on the text entered in any cell of a QTableView?

    Use delegate and create your own editor. For example, if the editor is an instance of QLineEdit, then you can simply set the maximumLength property to 1.

    Check this Qt example:
    Spin Box Delegate Example

    Hopefully can help you..

Similar Threads

  1. how to color a cell in a QTableView
    By JeanC in forum Qt Programming
    Replies: 13
    Last Post: 9th September 2015, 11:08
  2. Add QPushButton to cell in QTableView?
    By nikhil in forum Qt Programming
    Replies: 3
    Last Post: 14th July 2010, 10:01
  3. Different text styles in a single cell of QTableView?
    By xfurrier in forum Qt Programming
    Replies: 2
    Last Post: 23rd August 2009, 07:49
  4. How to tell if QTableView cell is visible ?
    By steviekm3 in forum Qt Programming
    Replies: 0
    Last Post: 2nd March 2009, 11:04
  5. how to get data from cell of QTableview
    By yleesun in forum Qt Programming
    Replies: 2
    Last Post: 9th January 2009, 15:31

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.