Results 1 to 2 of 2

Thread: Making an options/settings class

  1. #1
    Join Date
    Jun 2010
    Posts
    12
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    1

    Default Making an options/settings class

    This is possibly more of a general C++ question. I need to have application settings data available (including public slots, enum constants and member objects) to most of the classes in my program concurrently, but I'm not sure how to do that. I know I can use QSettings() to store and retrieve settings, but I'd like to try and make my own settings class. The first thing that came to mind was to create a pointer to it in every class, but initializing it gets messy fast with having to track the child/parent relationships between each class in the inheritance chain.

    I'm still learning about static functions and multiple inheritance, but I think what I want is to have each class inherit from my Settings class, and then make all of the get/set functions static, as well as the settings data members. If I understand correctly this will allow me to access the classes data without every instantiating an object of it, and each class that inherits from it can treat Settings get/set functions like their own? If anyone could help straighten out my thinking or point me in the right direction, I'd appreciate it. Also, while searching it seems I can't make static slots/signals, so in this case would I be unable to use them in such a class?

    EDIT: I tried creating a Settings class with static member objects and functions, and inheriting from it with those classes that needed access to either, and it seems to be doing what I want. Someone chime in if there's a better way to handle this!
    Last edited by weevil; 14th June 2010 at 08:02. Reason: updated contents

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    520
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 77 Times in 75 Posts

    Default Re: Making an options/settings class

    Hi you probably want a singleton.

    Ginsengelf

Similar Threads

  1. Replies: 0
    Last Post: 25th April 2010, 17:41
  2. Advanced PKG Options [S60]
    By ManuMies in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 30th November 2009, 11:52
  3. QTextEdit and some options
    By troorl_ua in forum Qt Programming
    Replies: 3
    Last Post: 29th June 2007, 22:03
  4. making a class aware of the gui
    By aegis in forum Qt Programming
    Replies: 10
    Last Post: 2nd April 2007, 23:56
  5. Zoom Options
    By Kapil in forum Qt Programming
    Replies: 2
    Last Post: 9th March 2006, 11:19

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.