Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7636013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:34:06+00:00 2026-05-31T07:34:06+00:00

Here is an idea: I have a list of parameters (name, type, value maybe

  • 0

Here is an idea: I have a list of parameters (name, type, value maybe something more – regex for input), grouped by sections. They are stored in xml-file (for example… maybe other format). I want to make a module, that builds “standard-looking” settings dialog rely on this file. Like this
settings
Sections names should be on the left as a list, and parameters, reffered to selected section, are to the right: name as label and value as some input field, wich type depends on type of parameter (lineEdit for text, spinEdit – for numbers, checkBox – for booleans, etc.)
Finally a question: is there “ready-for-use” dialog for my purposes ?
Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T07:34:07+00:00Added an answer on May 31, 2026 at 7:34 am

    I searched some time and didn’t find any decision. That’s why I decided to write it myself.
    Here’s a little description:

    1 Main concept

    If your program has some parameters, that you want to be editable from the GUI, you should just write xml-file in proper format, create an instance of class Config, call slot Config::show() and finally ask for necessary parameter via Config::get()

    2 Usage of class Config

    You can create it everywhere you wish. You can give an xml-file name/path either in c-tor or in Config::load() method. You can obtain any parameter in any place of your program by
    calling Config::get() method. Example of class Config’s usage:

    Config config( "full/path/to/settings.xml" );
    connect( settingsAction, SIGNAL( trigger() ), &config, SLOT( show() ) );
    ... 
    if ( config.get( "section_name", "param_name" ).toBool() ) {
        ...
    }
    QFile file( config.get( "section_name", "directory_for_log" ).toString() +
        "/prog.log" );
    

    3 Restrictions

    Config need QtCore, QtGui and QtXml. It uses C++11’s features.

    4 Xml-file format

    Sorry, but I’m too lazy to write full description, so I’ll write a full example with all features. I think, that you’ll understand them all 🙂

    <?xml version="1.0" encoding="System"?>
    <config>
        <section visible="true" name="First section name">
            <group visible="true" checkable="true" checked="true" name="First group">
                <value visible="true" type="text" value="192.168.1.1:1234" regexp="ip-addr:port" name="Ip address:port"/>
                <value visible="true" type="bool" value="false" name="Some bool value"/>
                <value visible="true" type="combo" value="Just three" items="The one;The two;Just three" name="Choose 1"/>
                <value visible="true" type="file" value="/etc/some/file.jpg" name="Picture or sound" filters="Images (*.png *.jpg);;Sounds (*.mp3 *.wav)"/>
                <value visible="true" type="radio" value="Fourth" items="First;Second;Third;Fourth" name="Choose 2"/>
                <value visible="true" type="dir" value="/etc" name="Dir for log"/>
            </group>
            <group visible="true" checkable="false" checked="true" name="Second group">
                <value unit=" cm" visible="true" type="int" value="18" min="1" name="Length" max="33"/>
                <value unit=" kg" visible="true" type="int" value="42" min="0" name="Weight" max="100"/>
            </group>
            <value visible="true" type="bool" value="true" name="Just bool"/>
        </section>
        <section visible="true" name="Second sect">
            <value visible="true" type="text" value="hello" regexp="(hello)+" name="Greet me"/>
            <value visible="false" type="bool" value="true" name="Invisible bool"/>
        </section>
    </config>
    

    here is a picture
    enter image description here

    and here is a usage of Config with this file

    std::ostream & operator<< ( std::ostream & os, const QVariant & var ) {
        if ( var.type() == QVariant::Bool ) {
            os << var.toBool();
        }
        else if ( var.type() == QVariant::Int ) {
            os << var.toInt();
        }
        else if ( var.type() == QVariant::String ) {
            os << qPrintable( var.toString() );
        }
        return os; }
    
    cout << "First group checked : " << cfg.get( "First section name", "First group" ) << endl;
    cout << "Ip address:port : " << cfg.get( "First section name", "Ip address:port" ) << endl;
    cout << "Some bool value : " << cfg.get( "First section name", "Some bool value" ) << endl;
    cout << "Choose 1 : " << cfg.get( "First section name", "Choose 1" ) << endl;
    cout << "Picture or sound : " << cfg.get( "First section name", "Picture or sound" ) << endl;
    cout << "Choose 2 : " << cfg.get( "First section name", "Choose 2" ) << endl;
    cout << "Dir for log : " << cfg.get( "First section name", "Dir for log" ) << endl;
    cout << "Length : " << cfg.get( "First section name", "Length" ) << endl;
    cout << "Weight : " << cfg.get( "First section name", "Weight" ) << endl;
    cout << "Just bool : " << cfg.get( "First section name", "Just bool" ) << endl;
    cout << "Greet me : " << cfg.get( "Second sect", "Greet me" ) << endl;
    cout << "Invisible bool : " << cfg.get( "Second sect", "Invisible bool" ) << endl;
    

    And finally, can you tell me the best way to publish source code ?
    Thank you.

    UPD: You can find it here https://sourceforge.net/projects/guisettings/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's what I have private readonly Dictionary<Type, List<object>> _cache; public IList<T> Get<T> (Expression<Func<T, bool>>
I have no idea what this means. But here is the code that it
Maybe I'm thinking about this the wrong way but here's the idea: Class A
I'm having a little problem with this setup here I have a list of
im trying to do something here but that error shows up i really have
The idea here is to get better programmers right out of college. I think
This is a weird one, but hopefully someone can give me an idea here.
Here's the idea, I'd like to make a service? that will look for a
Here's the idea: you commit your code to a repository and call a web
Here is the idea: When the user wants to see /controller/action, then I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.