JavaFX equivalent to fill_parent in android - javafx

I´m using JavaFX scene builder now for the first time and I´m wondering if there is any fill_parent setting to let for example the menu bar always have the size of it´s parent, even if the window is rescaled by code.
Is there any appproach to have such a behavior in the designer?

There is the function "Fit To Parent" that can be found by right-clicking on an element in a container. This function is not available for all containers, what container do you want to fill?

Related

Problem fitting TilePane's height and width to parent ScrollPane in SceneBuilder

I'm building a JavaFX desktop app using scenebuilder for the UI.
Here i have a tilepane inside of a scrollpane, i couldnt use the "fit to parent" option from the context menu in scene builder, i guess the solution is to give them -fx-id's and bind their width in the controller ?
I dont want to use any values so it all comes together nice when the user resizes the window.
how should i go about doing this?

Resizing Layout equal to MainWindow

When I run my program it will display all content properly, and when I resizing the main window, the layout along with all associated widgets remain fixed, rather than resizing with the main window. I used to increase my all widget and listWidget respect to window computer resolution size but still this not one work properly.
I used this one code finding the system height and width.
QWidget widget;
widget.resize(widget.width(), widget.minimumHeight());
QRect rec = QApplication::desktop()->screenGeometry();
int h = rec.height();
int w = rec.width();
// Increasing the listwidget size
ui->listWidget->setFixedHeight(h);
ui->listWidget->setFixedWidth(w);
//increasing the button size
ui->pushButton->setFixedHeight(h0.2);
ui->pushButton->setFixedWidth(w0.2);
At this link you will find two screenshots that illustrate my problem.
Please resolve to solve my problem. Thanks very much in advance.
When defining the layout of your windows and forms in Qt Designer you have to define each element of your form in advance, in order to have a working layout.
This solution is based on the screenshots provided in the comments to the question. Follow these steps:
Add an empty widget to the central area of your form, if there is nothing there. It will be used as a placeholder for the controls you will add later, and of course you can replace it with whatever widget you want. But you need it there to define a proper layout.
In the property panel, set the horizontal QSizePolicy of this widget to MinimumExpanding.
Add an horizontal spacer to the left side of your progress bar.
Define a minimum/maximum width for the white widget on the left (I guess it's a text area). As an example set the maximum width to 200
pixels.
Make the same for the QTabWidget on the right.
Give a minimum height to the Groupbox on top.
Then give the grid layout to the MainWindow.
You should get something similar in the designer view (I use a dark theme, yours will have different colors of course):
If you complete all steps you should have a nicely resizing window.
For the future: remember to integrally define your layouts, also using placeholder widgets when needed, read carefully the documentation about the widgets size policies (there are several, you need to play with them to fully understand each one) and keep in mind that Qt uses a container based approach which is different, as an example from those used by the .Net framework that relies on the concept of anchors.
EDIT : to answer questions in the comments
You will need to add a layout to any widget that contains other widgets, e.g. adding controls to your groupbox will require to give it a grid, horizontal or vertical layout in order to scale nicely on resize. Again use spacers and size policies to make it look the way you want. If you need to add or remove controls, or change their positions, you may need to brake the layout, rearrange and then set it again.
You can also select groups of widgets and give them a layout e.g. vertical, than another group and set them horizontal and so on... then give a grid layout to the container widget to build a compound layout.
There are endless possibilities, you just need to practice and go through trial and error as for everything else...
You can also do it all programmatically, check the Qt widgets documentation for this. But for complex layouts I would not go that way: it's a lot of code... and you have to compile and run to test every modification.
Using the QtCreator, within the designer you can simply right-click on the parent-widget and add a Grid-Layout.
This one resizes it's children to it's dimensions.

Why can't I set AnchorPane's resizable attribute?

I created a FXML file using JavaFX Scene Builder 1.1. An AnchorPane is created by default. Why can't I modify the resizable attribute?
Do you want to disable window resizing? If so, you can do that in your application program:
stage.setResizable(false);
Why you can't edit bounds
Checkout the javadoc on layoutBounds and boundsInLocal. You will notice that both are ReadOnlyObjectProperties, which is why you can't directly modify them in SceneBuilder.
How to resize a node in SceneBuilder
You can indirectly effect the bounds properties and directly set the resizable properties of the node by altering the min, pref and max height and width.
You can also set the pref size by selecting the pane to be resized and dragging the resizing anchors the surround the selected pane.
Further Information
You might want to read the Oracle tutorial on Tips for Sizing Nodes and Amy Fowler's presentation on JavaFX layout.
You can change resizeble using code
primaryStage.setResizable(false);

Qt: How to resize a window to its new content

I have a window containing a QScrollArea with a couple widgets in it.
Until now, I was creating the QScrollArea and its child widgets in the constructor of my window, and then I was resizing the window vertically to fit its content using resize(400, sizeHint().height()). So far, so good.
Now, I'm adding or removing widgets in the QScrollArea at runtime. What should I do, after having added or removed widgets, to make the window fits its content vertically? Should I call adjustSize()? resize(sizeHint())? Should there be a call to layout->activate() or maybe updateGeometry() first? Which size policies actually matter in this case? The ones of the window, or of the scroll area, or both? I tried to set them all to Expanding.
I'm using Qt 4.6 on Windows.
It seems that calling resize(sizeHint()) (without any other magic) after widgets were added to the scroll area actually does the trick. Somehow missed that the first time.

Can a modal-window-type blur be created for any Component in Flex?

I'm aware of PopUpManager and that custom modal windows can be created.
But let's say I have a simple Canvas(or any component) and when I show it the background needs to be blurred out like how PopUpManager does when a new pop-up is shown.
Is this possible?
Not without a lot of work. The PopupManager puts a blur on Application, and then puts the popup in front of the Application, but as a child of the SystemManager, so it's a sibling to the Application in the display list rather than a child. You could take a screen shot of the Application, run a blur filter over it, and place it as the last child of Application, and then place your component on top of that, but if you do that you might as well just use PopupManager in the first place.
I think the blurring has to do with how you set the alpha level on the component.

Resources