I want to add padding to an AdaptiveContainer and tried to use Spacing = AdaptiveSpacing.Padding but this seems to have no effect. Does anyone know what this flag supposed to do?
Related
I have a QGridLayout with QLabels in it that are displaying some values and the units to that values. For good readability I want the value to be left-aligned within the QLabel and the unit to be right-aligned.
At first I wanted to do this with QtStyleSheets but the only way I found was to change the text-alignment of the whole widget like this:
myLabel.setStyleSheet("QLabel {qproperty-alignment: AlignRight}")
My second thought was to do it via HTML but there I also encountered several problems. Here is what I tried:
myLabel.setText("<div align=\"left\">Value<\div><div align=\"right\">Unit<\div>")
This does the right thing, after that the value is left-aligned and the unit right-aligned, but they are not on the same line anymore. Nevertheless it appears to me the more promising approach. Unluckily I am not very familiar with HTML.
Can anybody help?
Or if you really just want go on with html in QLabel use table instead of div's. But #saeed is right, better use Qt Layouts and spacer between them.
Example with HTML:
myLabel.setText("<table width=\"100%\"><td width=\"50%\" align=\"left\">Value</td><td width=\"50%\" align=\"right\">Unit</td></table>");
I suggest you to use two Qlabels and a Horizontal spacer like image below , this is fast and you can let Qt handle whole design layout.
Hope someone could help me how to add a border(red) like below. This is a databar chart. I am adding a border on the properties but it shows border to all corners. I can't specify it to only one corner.
Design View
If it's really not possible. can someone suggest other solution? It should be dynamic too. It should be aligned with the blue ones. Thanks
Not Sure why its not working for you.. its a straight forward
Set BorderStyle: Default None & Left:Solid
BorderColor: Red
Sorry, I can't see the image uploaded with Question, due to some firewall .. you can try with above steps
Is there any way of adding some kind of automatic margin between two or more fillText()?
I have a set of fillText() that is changing every frame, they become longer and shorter, but I would want them to to have a fixed space between the text. I don't know how else I can explain this. I created a fiddle to show what I mean.
Example, if you look at the seconds counter, when there is only 1 character in there, the 'S' character is longer away from the seconds than it should.
How would I fix this? I'm pretty new to canvas. Thanks in advance.
Okay, so I found a solution. I'm now grabbing the width of each text element and using that, plus some more in the second argument of fillText().
https://jsfiddle.net/9tv44ja5/3/
^ Updated solution. It's a bit messy atm., will try to clean it up abit later.
I'm working on this nametag designer project, and because the elements are later added to pdf, i need to know the EXACT placement on the tag.
TextField's are giving me some problems, cause the textfield "padding" changes when you change the fontsize.
I either need to remove the "padding" or get the x,y position of the text inside the TextField.
Leading test:
Any ideas on this! Thanks!
I'm not sure what "padding" you need, but you can get all offsets with this methods: getCharBoundaries(), getLineMetrics().
Hey you all, just a quick question of what i havent found anywhere. Im adding a scrollpane to a JPanel, with 2 JScrollBars. One vertical and one horizontal. Everything works fine just that i dont want the ScrollBars to scroll using the arrow keys. How do i achieve this?
I´ve been checking out adjustmentlisteners but really havent found anything of high value to me. Thanks for any help!
you have to tweak the keybinding in the scrollPane's inputMap and point the navigation keys into nirwana, like:
InputMap inputMap = scrollPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
inputMap.put(KeyStroke.getKeyStroke("RIGHT"), "do-nothing");
// same for all navigation keys you want to disable
...
to find which keyStrokes are registered, look into the BasicLookFeel - the section in getDefaults which relates to "ScrollPane"
Beware: that's highly unusual, you user's might be annoyed!