In SceneBuilder I have set my root pane(Anchor Pane) to 1280 x 720 and it shows the same thing in preview, however when I run my code in NetBeans my program is shown bigger than my full HD screen (1920 x 1080).
To resolve this I lowered my set resolution in SceneBuilder to something less and now it shows a smaller window when ran from NetBeans but it looks zoomed in and the size is still bigger than what it should be.
What can I do in NetBeans to show accurate size of stage(window) i.e size that I have created in SceneBuilder.
You can use many methods and add them to anchorPane.
For Example:
anchorPane.setPrefSize(double prefWidth, double prefHeight)
In Netbeans. Here is link: https://docs.oracle.com/javase/8/javafx/api/javafx/scene/layout/Region.html#setPrefsize-double-
And you can find other methods in that documentation. For example: setMinWidth(double), setMinHeight(double), etc...
If you want to be 100% sure that your window is always 1280 x 720 then set:
anchorPane.setMinWidth(1280);
anchorPane.setMaxWidth(1280);
anchorPane.setMinHeight(720);
anchorPane.setMaxHeight(720);
where "anchorPane" can be Fx Id of your Anchor Pane.
EDIT: You can set them in initialize method.
Maybe you want to set size of Stage, then use stage instead of anchorPane.
Related
I'm trying to get a Designer fixed size mainwindow to display as it looks at its minimum size in Designer. If I set its sizePolicy to 'Expanding, Expanding', and adjust the size as small as it will go, the geometry is shown as [(0,0), 1378 x 756]. When I run the program it displays bigger than it needs to be, but I can resize it to its smallest and it looks good enough (picture on the left), although the bottom of the Random frame doesn't perfectly align with the label to its left.
If I use QSettings; the size from the .config file is 'size=#Size(1368 727)', but I can't set it to that in Designer. If I set the sizePolicy to 'Fixed, Fixed' at 1378 x 756 then it looks wrong when I run it and I obviously can't resize it (picture on the right).
two images as described above
What could be causing it and/or how can I fix it?
(I tried adding QApplication::setStyle(QStyleFactory::create("Fusion")); and its #include, from the first answer here, but no change)
Qt Creator 7.0.0 Based on Qt 6.2.3, Linux Mint 21 Cinnamon (ubuntu 20.04).
Eta: Typically; a bit more effort on my part has got it right. Mainly I think the label was too big for the space available for it. All looking perfectly aligned now and no more discrepancy between Designer's size (of the main window) and the .conf file.
I'm using JavaFX. When i add an imageview node to the stack pane and then run the application, I can only see the image after manually resizing the window (dragging the edge of the window with my mouse).
It will also show up if i setTranslateX or setTranslateY the image away from its original location. But if I want it to just stay there, I have to manually resize the window to see it. Has anyone encountered this? Is it a bug I just have to deal with?
Thanks
I'm using a PiTFT on my pi and running a JavaFX program. I got the output going to the PiTFT by running fbcp in the background.
I had to set disable_overscan=1 in /boot/config.txt to get it to show the whole image. That all works fine now.
My problem is that the touch screen calibration doesn't seem to effect JavaFX apps. The X and Y axis are swapped. Does anybody know how to calibrate the touch screen for JavaFX apps?
I don't know if this is a problem with the touchscreen driver for the PiTFT or a JavaFX configuration problem, so I'm going to post the same question to the adafruit forums and if I get an answer in one place, I'll copy it to the other.
I've struggled with the same problem today, and I managed to figure it out.
The PiTFT is by default a portrait display with a resolution of 240x320. The driver conf is originally made to rotate the display. The touchscreen setting for X are aware of that and have the rotate option set accordingly. And yes, this will not affect JavaFX since it doesn't run in X.
What I did:
in /boot/config.txt
disable_overscan=1
framebuffer_width=480
framebuffer_height=640
#set specific CVT mode
hdmi_cvt 480 640 60 1 0 0 0
#set CVT as default
hdmi_group=2
hdmi_mode=87
hdmi_force_hotplug=1
With this, the main display resolution is set to 480x640, and overscan is disabled.
Next, in /etc/modprobe.d/adafruit.conf, change the rotate option to be 0.
Save everything and reboot. Then fbcp & java Main, and it should be working OK.
Btw, be aware that I used the pre-built raspbian image from adafruit.
I have created an application with a screen resolution of 640 x 360 for the nokia n8. It includes a lot of flickables, labels, etc. I want it to run on the nokia e6 with a resolution of 640 x 480.
Up to now I have simply copied the the QML file and modified it for the new resolution but it's getting a little tiresome to do it for each update. I want to know if there is any simple way I can get it to automatically fit the output to any screen resolution? Or if there is something else I can do to simplify my task. I would prefer not to use anchors because it makes it too complicated to design the QML file.
How about using QApplication::desktop()->availableGeometry() to set the geometry of your application window?
From the docs:
QDesktopWidget::availableGeometry()
Returns the available geometry of the screen with index screen. What is available will be subrect of screenGeometry() based on what the platform decides is available (for example excludes the dock and menu bar on Mac OS X, or the task bar on Windows).
Addressing your comment below:
does it re size the entire screen
The const in QDesktopWidget::availableGeometry() const tells you that you can be pretty sure that the function doesn't alter anything. You'll need to do the resizing yourself.
Edit: The QML docs should give you the information you need to automatically change your application geometry. You could either change the geometry of the QML object from C++ or define your available screen geometry as a Q_PROPERTY and access it from QML. I'd recommend the former, as hooking up to the signal QDesktopWidget::workAreaResized might help you on mobile devices where your available geometery may change.
Actually you should avoid hardcoding the interface pixel by pixel and start using anchors. Ther will be some phones that have yet another screen resolution and then you have to create new QML for each of them. With anchors you can let the content fill all available space
I am using Qt to construct an application. My MainWindow consists of an image of a map which I would like to be resized to the fit the window. This means when the window gets smaller the image gets smaller and vice versa. When the user selects a point on that image I want to remove this feature. I am new to Qt and haven't been able to figure this out. I am using QGraphicsView for this.
QGraphicsView::fitInView