How to layout out a component differently depending on the amount of space available? - apache-flex

I am trying to build a sort of button bar in Flex - something like the horizontally laid-out bookmark bar you'd see in most modern web browsers, where when you run out of horizontal space, you can click on the arrows button(>>) to get a drop-down to see the rest of the items which did not fit into the horizontal space. Problem is, how can I know how much horizontal space is available for me to tell how many buttons to render into the button bar? This need doesn't appear to be support by the general layout manager framework.

You can check the width of the parent container, and if that is less than the combined widths of your objects that you've attached with AddChild or AddElement, then you don't have enough space and need use your arrow functionality.

Related

Layout differences between Qt Designer and running program

I am trying to make a basic wireframe design before I add colours, etc. As seen in the two pictures below, the sizing of the layouts is very different in designer and when the program is run. I have tried changing the layout stretch but it has no effect.
Designer:
Running program:
You need to decide what should happen when the window is resized larger than the size shown in Qt Designer. Presumably, you don't want the "Logo" and "Date" rows to expand to take up the extra vertical space, and you don't want the "Modules" row to expand either. So the extra space will have to go at the bottom.
The simplest way to achieve that is to put an expanding spacer immediately below the "Modules" row, but inside the outer layout. This will push everything up against the top of the window, and only allow space to grow at the bottom.

Add fixed sized items to grid layout in correct row

I am trying to create a grid layout of images kind of like how google images does it.
I want to add fixed sized images left to right, top to bottom but I am having trouble is figuring out when adding another image to a row would make it not fit and then decide that that images should be placed in a new row.
Also when the window resizes it should move images into/from rows based on how many it can fit in.
Ive got a scroll area with a grid layout in it which is fine if I know what can fit, but I can't figure out how to make it move items if say the window width is shrunk, and say an item needs to be moved down 1 row which moves other etc.
Assuming you are using QWidgets I'd suggest you to use QListView which does the layouting for free, if you want more control on how items are displayed use a QItemDelegate. For QListView the view mode should be set to QListView::IconMode so that you have a grid of items and not a list.
But if you are using QtQuick things are much easier, a GridView with Image delegates would do what you want really quickly and using GPU power to build you UI.

User resize able widgets like 3D modeling programs

I am using qt designer and python. I want to make a layout where a user can drag widgets to control the size while at the same time scaling properly with the window. Basically all 3d modeling programs have this function, usually it has a top left right and perspective view. The user can drag the edges to resize each view and it will maintain that aspect ratio when the main window is resized. My question is similar to this: active resizing of widgets inside mainwindow but I would like to do it in qt designer.
So what I have found is the layout horizontal/vertical splitter. However I am only able to layout two widgets horizontally, and another two widgets horizontally, then grid layout. This makes it look similar to what I want except I want the top and bottom horizontal layouts to also be re-size able.
Thanks
Edit:
I have been able to do this with putting both horizontal split views in a group box and then splitting the two group boxes, however that makes each widget independent and does not let the user grab the middle axis to control all 4 views.
You are essentially asking for a splitter than works across two axes - no such standard widget exists. So you will have to create your own.

Flex: preventing tree's vertical scroll bar overlapping view

I have an mx:Tree, but when the vertical scroll bar appears, it overlaps the content of the tree (odd that the horizontal bar does not). That might be acceptable for the text, but the stripe that I create using the item renderer, for certain items, seems to make it an anathema to the QA guys. How can I keep this from happening?
I have an idea for a workaround: I could make use the item renderer to stop the drawing a little bit short of the right side of the view (not that I can reliably get the width of a scroll bar) but I can't even figure out how wide the displayable part of a tree is--all the properties of a tree seem to be about its entire width, which includes the entire area coverable using the horizontal scroll bar. However, the blue stripe signifying a selected item doesn't seem to have that problem--it stops short of the scroll bar. In any case, when trying to find the displayable region, I don't know if I could handle the added complication of when the horizontal scroll bar is moved. Much better if someone could tell me how to put the veritcal bar outside the displayable tree area (or shrink the displayable area, of course). Thanks.
I'm using the Flex 3.5 SDK
I was able to find the solution when researching horizontal scrollbar issue on list and tree component. The blog to which it links eventually shows a kind of hacky solution (in the readers' comments) that shows how to make sure that none of the drawing is done beyond a certain boundary.

qt unexpandable layout?

Ok, here is my problem:
I have a vertical layout which contains a QPlainTextEdit and a horizontal layout (containing 2 QPushButtons) below the text edit.
The vertical layout is just a part of GUI, and gets resized depending on screen resolution. Btw. it is a mobile app, so I don't have a lot of space on screen.
Push buttons have some text which is dynamically set, I don't know it from the beginning to code it manually.
My problem occurs when the text in push buttons is big, and my whole vertical layout is expanded to fit the buttons.
How can I make the vertical layout unexpandable? note, that this is different from "fixed" because of different screen resoulutions.
I'd just like the clip the buttons if they do not fit, but keep the layout width untouched.
Anyway to do this?
You'll need to set the maximum width for the buttons, not the layout, which is only widening to fit the wider buttons. Check out the docs on QPushButton and look for QWidget inherited functions called setMaximumSize or setMaximumWidth.
You can always GetWidth() on the button when it is an appropriate size, then setMaximumWidth using that value since you wouldn't ordinarily know this. Pick an appropriate default text size/val and use that to create your "dynamic" default since this is going on screens of varying size.

Resources