0

I am designing a GUI in Qt that has placeholders for a number of images (images will be set and updated at run time) along with some input fields (QLineEdits with QLabels grouped into QGroupBoxes). I am using a technique similar to the answer here:

How do I make an image resize to scale in Qt?

for the image display widgets. Some are a class that inherits from QWidget that can draw an aspect-scaled image, others are a class that inherits from QLabel that can do the same and also display text. These are custom C++ classes.

The problem I am having is with the layout and getting things spaced correctly. I am using Qt Designer to layout the GUI. Since the image widgets are "empty" they don't exert a lot of "force" on the other widgets and the other widgets tend to dominate even though I don't need the other widgets to be that big. The QLineEdits especially like to be as wide as they can be. I want to GUI to be adaptable for different sizes (to accommodate different screen resolutions) so I don't really want to set a lot of sizes manually if I can help it.

I do not have a lot of experience in Qt and managing layouts. What I know I have mostly learned from playing around with it. I have tried searching for similar situations without much success. I can't figure out the terms to use for my specific situation. Does anyone have any suggestions for what I can do to better control the layout? Alternatively, are there any good resources for learning how to manage Qt's layouts? The Qt documentation I have looked at is fairly basic. There are a lot of options, most of which I am unsure exactly how they should work, and the trial-and-error approach is getting to be too cumbersome for more complex layouts.

I am using Qt 4.8.

Sorry to be vague. This is a work project and I would rather not post exactly what I have. And coming up with a generic example will take time. I think my questions are generic enough that it shouldn't matter. If a more specific example is needed, I can try to throw something together.

Edit:
Here is what the layout looks like in Designer right now. The black boxes are redacted labels. The orange boxes are where images will go. The one in the top-left corner is a particular problem. I currently have the top and bottom halves on the left in a splitter in an effort to make things fit better. I think that may be making it worse.
https://i.stack.imgur.com/nRRg3.png (long-time reader, first-time poster :-/)

Making the "What I want it to look like" picture is going to take a bit longer. It may be easy to see what I don't like. The input fields need to be much smaller to make room for the images.

Edit2:
And here's something closer to what I would like. The upper-left and right-hand images are larger and actually visible. I might like the boxes in the lower-middle to be even bigger, but there's only so much room. If I can get the layout right, I'm hoping that will optimize the size of everything for a given window size.
https://i.stack.imgur.com/yvLvi.png

Community
  • 1
  • 1
plasmoidia
  • 604
  • 6
  • 15
  • can you put an image of what you want to do (using a designer snapshot), and one of what really happens? – UmNyobe Dec 12 '13 at 16:22
  • @plasmoidia, did you try different size policies in the designer? – qurban Dec 12 '13 at 20:18
  • @qurban I have. But I don't understand what they mean. That's one reason why I'm asking for clarification. The only thing I have found is that the "Maximum" policy causes things to be as small as possible (okay...) and everything else seems just to be the same big size. – plasmoidia Dec 12 '13 at 20:32
  • Posting an edit here since apparently I can't post more than 2 links, yet I currently have 3. ?! Edit3: Okay, I have been able to get something much closer to what I want by making use of the "stretch" options, like referenced here: [Layout : How to make one widget 3x the rest in a verical layout](http://stackoverflow.com/questions/18215013/layout-how-to-make-one-widget-3x-the-rest-in-a-verical-layout?rq=1) Here's what it looks like now. I left off the orange boxes as you can more clearly see where images should go now. [Latest Layout](http://i.stack.imgur.com/GfI9t.png) – plasmoidia Dec 12 '13 at 21:20

0 Answers0