Results 1 to 6 of 6

Thread: Question about a handler of various types of parameters

  1. #1
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question Question about a handler of various types of parameters

    Hi everybody, I'm programming an application that does some processation for a specified input. The results of this processation are various parameters that I have to save at disk. These parameters are basicly integers and doubles. Well, I have implemented a handler class to save / load these parameters from disk. In some cases, I have to left some parameters as "unspecified". I would like to know what's the best / elegant way to implement it: consider it unspecified when the user sets the value for the parameter with a special value (negative values, for example), with an auxiliar method to set the value unspecified and save it at disk with a special value that manages the handler, ... Could anybody suggest me something?

    Thanks a lot.
    Last edited by Dark_Tower; 16th March 2006 at 23:16.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Question about a handler of various types of parameters

    Could you provide an example? Your explanation is a little unclear.

  3. #3
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Question about a handler of various types of parameters

    Quote Originally Posted by wysota
    Could you provide an example? Your explanation is a little unclear.
    Yes, sorry. I mean that not always all the parameters with the result of the processation represent strictly a "value". In some cases, if the processation has been wrong or in some special cases , I need to set some parameters with a special value that represent that the parameter is "unknow", "unspecified", "invalid" or calculated "manually" by the user, for example. In these cases as you see these parameters dont' have a value, simply inform of something. I would like to know how it's the best way to manage these parameters that in some cases have value (int or double) but in other cases dont't. I've thought with special values that the user will set to the parameter using the handler: positive values -> valid values, negative values -> -1 = "Manually Processed", -2 = "Unknow", etc. But I don't know if it's the best way or could be another way to make it more 'elegant'?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Question about a handler of various types of parameters

    Maybe a structure with validity flag? Something like QVariant and its isValid() member.

  5. #5
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Question about a handler of various types of parameters

    Quote Originally Posted by wysota
    Maybe a structure with validity flag? Something like QVariant and its isValid() member.
    Yes wystoa QVariant could work, but how could I determine the cases that the parameter is valid but it doesn't represent a value from the cases that the parameter represents strictly a value. For example, in some cases I want to indicate that the parameter is "unknow" because becomes from a manually processing. In this case I want only to indicate this fact without any value.
    Last edited by Dark_Tower; 17th March 2006 at 18:01.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Question about a handler of various types of parameters

    Qt Code:
    1. class SomeClass
    2. {
    3. public:
    4. enum Status { Unknown, Invalid, Valid, ... };
    5. // ...
    6. private:
    7. Status _status;
    8. int _value;
    9. }
    To copy to clipboard, switch view to plain text mode 

  7. The following user says thank you to jacek for this useful post:

    Dark_Tower (17th March 2006)

Similar Threads

  1. Question about mouse,keyboard event handler?
    By Sheng in forum Qt Programming
    Replies: 2
    Last Post: 24th February 2009, 07:50
  2. Message handler question
    By bruccutler in forum Newbie
    Replies: 10
    Last Post: 19th May 2007, 21:26

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.