Results 1 to 5 of 5

Thread: QTableWidgetItem with specify type

  1. #1
    Join Date
    May 2011
    Posts
    18
    Thanks
    2

    Default QTableWidgetItem with specify type

    Hello,

    I would like to specify the type (int, double, string) of each Item of my QTableWidget
    I really want to use QTableWidgetItem to do it and no spinbox or lineEdit for performance issues.

    Is there a way?

  2. #2
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: QTableWidgetItem with specify type

    Setting user type in the constructor?

  3. #3
    Join Date
    May 2011
    Posts
    18
    Thanks
    2

    Default Re: QTableWidgetItem with specify type

    QTableWidgetItem::QTableWidgetItem ( int type = Type )
    I don't understand this "type".
    How does it work if I want to get a int or a string?

  4. #4
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: QTableWidgetItem with specify type

    create some enum like this:

    Qt Code:
    1. enum MyItemType { INT = 1, STRING = 2, DOUBLE = 3 };
    To copy to clipboard, switch view to plain text mode 

    Then use your types to set it to the item in the constructor. With int QTableWidgetItem::type () const you can get what type you have set

  5. #5
    Join Date
    May 2011
    Posts
    18
    Thanks
    2

    Default Re: QTableWidgetItem with specify type

    The point of all this is to make the item editable with the good type (the user can't put "toto" for an int item)

    I'm not sure I understand the thing you've just explained, but it doesn't seems to me that it will check what the user writte in the item no?

Similar Threads

  1. Replies: 7
    Last Post: 19th April 2011, 12:20
  2. How to get a QPixmap from a QTableWidgetItem?
    By gboelter in forum Newbie
    Replies: 8
    Last Post: 10th October 2010, 10:52
  3. QTableWidgetItem dynamic type, how?!
    By Onanymous in forum Newbie
    Replies: 2
    Last Post: 13th May 2010, 13:29
  4. Replies: 2
    Last Post: 22nd December 2009, 20:52
  5. Type and User Type
    By campana in forum Qt Programming
    Replies: 1
    Last Post: 27th February 2006, 23:22

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
  •  
Qt is a trademark of The Qt Company.