views:

125

answers:

4

In my project I going to generate a user interface through programming. Scalability of this UI is very important requirement.

So far I am using two dimensional graphics for generating the UI. I think there may be different solutions but for the moment I know only two.

First one is supplying X,Y coordinates of each two dimensional graphic on my UI.(I do not prefer this solution because I do not want to calculate X,Y coordinates of each graphic. For the moment I don't have a logic for doing this easily)

Second one (which is currently I am using now) is using layouts which organizes its contents according to size of item. In this solution I don't have to calculate X,Y coordinates of each item. (Layout is doing this for me.) But this approach may have its own pitfalls.

I am very new to user interface programming. Can you give me advice about this issue?

A: 

There is Qt Designer (GUI Builder) which allows designing GUI like in Visual Studio.

Calculating X,Y by hand is a bad approach - it is absolutely inscalable.

marpetr
I am not using predefined Qt Widgets. So Qt Designer does not solve my problem.
onurozcelik
+2  A: 

The general rule I follow is that you should always use layout containers unless you have very specific reasons to use an absolute layout. The only real times I use absolute layouts is when I'm implementing a weird custom layout that doesn't fit easily with built in layout managers.

Layout managers will make your life much easier. Handling resizing windows or variably sized content is made significantly easier with layout managers.

I can't remember every having a problem with qt's built in layout stuff.

Herms
A: 

Don't reinvent the wheel: Inherit your objects from UI objects e.g. panels so you could use the UI techniques from those objects. For the rest use containers or any other layout objects

PoweRoy
+1  A: 

I am assuming you rail map only needs to be a schematic of the real track layout, you could create components that are all layed out on a grid, and for each grid cell you implement a simple layout algorithm, depending on your requirements you could just state that one grid cell can only have one actual control on it (and make the cells smaller) or for larger cells you have fixed spots for each type of control, or just arrange the controls within a cell from left to right/top to bottom, whatever works for you. You could also subdivide the cells themselves into subcells to constrain the controls. So that when you scale the whole, each cell can then tell the control what size it should be.

It might also help to implement things as layers on your display, for example make the track layer separate from the control layer.

You are working on a very specific "non-traditional" ui you will need some solutions that fit your problem.

I don't know if you are doing this already, but think if you can implement a data driven approach for the configuration of your UI. Don't hardcode the layout, separate the layout functionality from the actual operational parts and move them into a file that can easily be changed.

It sounds you have some kind of working solution but you said "I do not prefer this solution because I do not want to calculate X,Y coordinates of each graphic", if you have graphical controls that can be placed anywhere on the screen though code, it is probably not a big step to have an editor where a user can place these controls. It might not be as much effort as you think, especially if you are already using a configuration file for your UI instead of hardcoded values.

I have recently done a lot of work changing the normal look of qt elements through styles, but I don't think that the normal qt-gui parts will be enough for your endeavor, but the QGraphicsView subsytem would probably be a good fit it does scales well and handle interactions with large number of elements well, but it is hard to give you a more specific answer without knowing more details

Harald Scheirich