PDA

View Full Version : Help Request for designing .ini editor application in Qt for a total newbe



Bziur
1st March 2014, 15:01
Hello there, this will be my very first post on this forum

Why I need help
As mentioned in title, I'm a total newbe to projecting my own applications,
I finished C++ course on University and know the general principles of object programing,
but I never really wrote a GUI application from a scratch.

What advice do I need
I need to know the general approach I should take, what Qt elements would fit best for the purpose,
what approach should I take in regards to data representation, save and load mechanics, how to combine it with
the interface and stuff.
If you've got good reading materials in regards to the topic, I'll be glad to read them instead.
I don't want you to write the program for me, because I want to learn how to do it myself, I just want directions.

What I intend to create
I want to create an application that will allow me to easily modify certain .ini files, which represent
HUD elements in a game. I want to easily place them on the screen, easily be able to mess around with the textures of the element
(by selecting region from tga graphic file), and be able to rearange them in fashion of GIMP layers.

The Ini Structure consists of

A main ini file, containing list of ini files with elements to load.
ini files containing a header with offset property, and elements separated using a comment line
elements of 3 types: Text, Icon(aka textures), Effects, all of which are represented on screen as rectangles and contain properties
properties of various nature, such as ID, hud group, hud layer, rectangle, and various other properties. I could load them all, but I see no need to, as some of them are irrelevant to the program purpose.
A single tga texture file that some elements such as icons can select an area of to be used as their texture



So let's go through what that application will do from start to end:

Load (parse) hud data from .ini files/create new project with default data values and store them in a structure of some sort (List? Hash?)
Represent the hud elements in some kind of view, with list of them, in which I'd be able to select them, move around (accurately), change anchor points, resize them, mess with layers they will be displayed on, also easily group them and break the group on demand.
Show dialog that will display a tga graphic, and allow me to select the region off this graphic, and then pass it to the view.
Allow me to Save the modified data in the a structure of .ini files.



Main challenges:

Coming up with a proper design of application, that wouldn't create a mess in memory, in code, that would be object-oriented,
relatively simple and intuitive.
Finding the best way of representing the elements on screen. I already found out that I can use QGraphicsView, I'm not sure though how to connect the whole graphic elements and loading/saving mechanism, nor how should I approach edit mode changes or event handling.

ttimt
2nd March 2014, 03:25
Starts with opening Qt

ChrisW67
2nd March 2014, 22:49
Nothing described is beyond a C++ program using Qt for support. You need to start with Getting Started Programming with Qt Widgets (http://qt-project.org/doc/qt-5/gettingstartedqt.html), the documentation (http://qt-project.org/doc/) and the numerous examples (http://qt-project.org/doc/qt-5/qtexamplesandtutorials.html). "C++ GUI Programming with Qt 4" by Blanchette and Summerfield is a good resource (you will need to make minor adaptation for Qt5 but the principals are still good). The first edition is available online (http://www.qtrac.eu/marksummerfield.html) the second ed is still in print.

QGraphicsView seems a reasonable base for a game scene editor.
You will need to find a way to read the (unusual) Truevision TGA files as Qt does not contain one.
Questions of how that view of your data structure is tied to the data structure, and how that data structure is related to its persistent format are far too broad to answer. They are strongly dependent on exactly how the data structure looks and operates.
If the INI files are sufficiently generic then QSettings may be able to read/write them, but it's more likely you will have to roll your own with QTextStream and QFile.