Results 1 to 2 of 2

Thread: How to QTableWidget default values on insertion?

  1. #1

    Default How to QTableWidget default values on insertion?

    Hi all!

    I'm trying to make some tables where some fields have a default value.
    When a new record is inserted into these fields, they should be filled with their default values.

    I am having difficulty doing that. I have several different tables, all inherits some methods of a base baseclass (modified QTableWidget), such as keyEvents.
    In these events I use the function for inserting rows. So I could not just put the defaults after.

    Is there any method that can be re-implemented to run every time a new row is inserted? Or should I do otherwise?
    I thinked about... I can make a virtual method in the baseclass and call it after the row insertion, then re-implement in the child class. Is this a better way?

    Sorry, for my bad english!

    If needed, I can post the code here.

    Thx!
    Last edited by RawArkanis; 20th April 2010 at 02:42.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: How to QTableWidget default values on insertion?

    As I understand you, you have a base class with a function that creates a new row with several items.
    So why do you not just put the desired values there? Make a member variable where you store the default values (this variable is defined by each subclass) and use these values while create your new row.
    Qt Code:
    1. class BaseClass{
    2. QList<int> defaultValues;
    3. void createRow() {
    4. // use defaultValues
    5. }
    6. };
    7.  
    8. class Child : public BaseClass
    9. {
    10. public:
    11. BaseClass() {
    12. defaultValues = //...
    13. }
    14. }
    To copy to clipboard, switch view to plain text mode 

    Of course a private member variable with a proper setter function is nicer...
    Last edited by Lykurg; 20th April 2010 at 07:05. Reason: updated contents

Similar Threads

  1. Replies: 0
    Last Post: 9th March 2010, 13:02
  2. QTable Widget
    By kavinsiva in forum Newbie
    Replies: 5
    Last Post: 23rd October 2009, 13:50
  3. Replies: 4
    Last Post: 3rd May 2009, 18:32
  4. C++ and default values for functions
    By guestgulkan in forum General Programming
    Replies: 4
    Last Post: 2nd January 2007, 22:53

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.