Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to use a validator with QTableWidgetItem?
Forum Updated to NodeBB v4.3 + New Features

How to use a validator with QTableWidgetItem?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 3.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LeeMinh
    wrote on last edited by
    #1

    Assuming I have a QTableWidgetItem item and I just wanna validate data that users enter. Example, users only enter a number into that item otherwise the program will show a warning dialog.

    I also search on "that document page":http://harmattan-dev.nokia.com/docs/library/html/qt4/qtablewidgetitem.html but I didn't find similar function with setValidator() function.

    How can I use a validator for that QTableWidgetItem item?

    Thanks!

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      If I'm not mistaken, you could fill the table->setCellWidget with a pointer to a QLineEdit and set the validator on that widget. Otherwise get the 'cell changed' (or something like it) and do a manual validation there and report back to the user. The first would be my preference.
      Greetz

      Greetz, Jeroen

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qxoz
        wrote on last edited by
        #3

        Or you can create custom delegate for that.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved