Qt Designer adds excess 1 pixel spacing
-
OnePixel.ui ----------- <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>OnePixel</class> <widget class="QWidget" name="OnePixel"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>200</width> <height>200</height> </rect> </property> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> <property name="minimumSize"> <size> <width>200</width> <height>200</height> </size> </property> <property name="maximumSize"> <size> <width>202</width> <height>202</height> </size> </property> <property name="windowTitle"> <string>OnePixel</string> </property> <property name="styleSheet"> <string notr="true"/> </property> <property name="sizeGripEnabled" stdset="0"> <bool>false</bool> </property> <layout class="QVBoxLayout"> <property name="spacing"> <number>0</number> </property> <property name="leftMargin"> <number>0</number> </property> <property name="topMargin"> <number>0</number> </property> <property name="rightMargin"> <number>0</number> </property> <property name="bottomMargin"> <number>0</number> </property> <item> <layout class="QVBoxLayout" name="verticalLayout"> <property name="spacing"> <number>0</number> </property> <item> <widget class="QLabel" name="label"> <property name="minimumSize"> <size> <width>200</width> <height>100</height> </size> </property> <property name="maximumSize"> <size> <width>200</width> <height>100</height> </size> </property> <property name="text"> <string>TextLabel</string> </property> </widget> </item> <item> <widget class="QLabel" name="label_2"> <property name="minimumSize"> <size> <width>200</width> <height>100</height> </size> </property> <property name="maximumSize"> <size> <width>200</width> <height>100</height> </size> </property> <property name="text"> <string>TextLabel</string> </property> </widget> </item> </layout> </item> </layout> </widget> <resources/> <connections/> </ui> OnePixel.js ----------- util.loadUIFile( "OnePixel.ui", "OnePixel" );
-
Ah, and within the vendor tool, to launch the .js, select PlugIns > CAN/CANopen Scripting, then Load, and nav to the .js
-
Hi
What is "application-level widget" ?
the centralWidget in mainwindow ? -
Hi mrjj,
I am probably using the wrong terminology completely - do correct me !
But by 'application-level widget', I mean the QWidget at the root of the hierarchy, within which all other widgets reside.
Namely, as defined starting on line 4, within the OnePixel.ui source, within my previous post.We're not using C++, just Qt Script, with just a .js file, and a .ui file, source per previous post. Our vendor tool, which is a Windows .exe, has a dialogue as mentioned, for opening the .js file.
The vendor provides a number of custom script functions, one of which is called util.loadUIFile( ), for loading the .ui file. That function call be seen in OnePixel.js, in my previous post.
I guess behind the scenes, within the vendor Windows .exe source code, concepts of centralWidget and mainwindow, could well exist. But those are hidden from view for us, within their undisclosed source.
Are centralWidget and mainwindow, standard names and concepts, with regular full C++ Qt development ?
I really need to set aside some time, to study Qt properly. But rushing against a looming project deadline, too much still to do, not enough time, usual story ..
Best regards,
David
-
Oh, btw, if you were to download the demo version of the vendor tool, from the mentioned weblink, as below, then after installing, the PDF manual for the vendor-special functions, can be found in
C:\Program Files\emtas\CANopenDeviceExplorer\doc, filename cde_script_api.pdf.https://www.emtas.de/en/download/canopen-deviceexplorer-demo/
-
Hi
Makes perfect sense now :)-Are centralWidget and mainwindow, standard names and concepts, with regular full C++ Qt -
development ?Well yes as a Default project has a default QWindow type that is a widget with docking
abilities. Supporting that it comes with a inner plain widget called centralWidget that is
the main client area of it and its often a gotch when starting up. ( you think u insert directly to the window)Other than that, its just as normal to use any widget as window as its just a flag.
I read you post a few times and still not 100% sure what the issue is. :)
I read it like
I put in some layouts. I set min/max and when i run it i can make it 2 pixels more that
it should be allowed to ?
(even with fixed Policy)
Something like that ? -
Hi,
Things are actually a little bit weirder than I thought: Rather than Vertical Layout having a 1 pixel inner box, it's actually a more like a closing square bracket ] surrounding the content, 1 pixel top and bottom, 2 pixels on the right, and no pixels on the left.
I found that, by placing in the styleSheet property for the first label, background-color:blue;
And in the styleSheet property for the second label, background-color:green;
Everything else, left exactly per the OnePixel.ui source in my post.
Checkout the following runtime screengrabs. First is as-is. Second is with window dragged out, from 200 by 200, to 202 by 202. You can see the little white sliver of the ] enclosing the blue and green.
In both labels, in the QFrame section, I then tried changing lineWidth, from the default 1, to 0. No change to behaviour.
And then for both labels, in QLabel section, under alignment, I tried changing Horizontal from the default AlignLeft, to AlignHCenter. No change to behaviour, except for centering the TextLabel text, within the blue and green panel.
Lastly, for each label, in the QWidget section, I tried changing layoutDirection, from the default LeftToRight, to instead, RightToLeft. I've never had need to look at that property before. Lo-and-behold, the ] changes to a [, if you're with me.
So as follows, when dragged out from 200 by 200, to 202 by 202:LayoutDirectionAuto is the same as LeftToRight.
Best regards,
David
-
Ah, my recent posts, crossed with your reply
Yes, your summary pretty much sums it up
Although in our actual application, it's 12 pixels more height than it should be, not 2 as in the example
And that's because of
]
]
]
]
]
] -
Btw mrjj, does that Champion flash mean you're a Qt staffer ? Can we tell on this forum if someone is an Qt support person, who might have the ear of the Qt devs ?
-
Hi
Ok its actually 12 pixels that is a lot.
Nope, im just a private person. This is a user forum and paid support is
available via other channels. (as in , not so much staff here but they host/pay the server)However, its possible to speak to the devs at
http://lists.qt-project.org/mailman/listinfo