Within the documentation for the Qt QML Tumbler Element in Qt 5.15 (https://doc.qt.io/qt-5/qml-qtquick-controls2-tumbler.html#displacement-attached-prop) the displacement property Tumbler.displacement is described as:
This attached property holds a value from -visibleItemCount / 2 to
visibleItemCount / 2
However, when I print Tumbler.displacement within my delegate component I get values that are larger/smaller than visibleItemCount/2 . Does everyone experience the same?
In addition, the documentation is strange here as well. Because the following example is said to
the item below will be 40% opaque when it is not the current item, and
transition to 100% opacity when it becomes the current item
And the JS looks as:
0.4 + Math.max(0, 1 - Math.abs(Tumbler.displacement)) * 0.6
Based on the text before the example, I'd have expected:
0.4 + Math.max(0, 1 - Math.abs(Tumbler.displacement)/(visibleItemCount/2.0)) * 0.6
Do you agree?
I came across all these, when I was facing the issue, that all delegates were printed on the same location fully overlapping each other. Somehow Qt is not able to place the items correctly (using Qt 5.15.2 and Quick Controls 2.15).
Related
I need to get the actual height of QTextDocument in order to be able to set the containing QPlainTextEdit to a minimum height (while keeping its width constant) so that it shows the whole content without the vertical scrollbar. I tried to follow this question (closed with with accepted answer) How do I determine the height of a QTextDocument? but it does not do what it promises.
A piece of code:
from PyQt5.QtWidgets import QApplication, QPlainTextEdit
app = QApplication([])
w = QPlainTextEdit()
w.setPlainText("Hello!")
print(w.document().size())
w.setPlainText("Hello!\nHello again!")
print(w.document().size())
prints out:
PyQt5.QtCore.QSizeF(35.0, 1.0)
PyQt5.QtCore.QSizeF(64.0, 2.0)
It seems that the width is measured correctly in pixels but the height just shows the number of lines instead of pixels. I think multiplying it with font pixel metric height does not help because there can be mixed formatting (in general it can be a rich text / HTML) and line spacing, document margins and maybe some other complicated stuff based on implementation details... etc.
So is there a way out?
So I finally found a solution but it is really ugly. If anyone knows anything better, please publish it.
from PyQt5.QtWidgets import QApplication, QPlainTextEdit
app = QApplication([])
w = QPlainTextEdit()
# test various formatting
w.appendHtml("<h1>Hello!</h1>")
w.appendHtml("<b>Hello!</b>")
w.appendPlainText("Hello!")
doc = w.document()
layout = doc.documentLayout()
h = 0
b = doc.begin()
while b != doc.end():
h += layout.blockBoundingRect(b).height()
b = b.next()
# magic formula: I do not know why the document margin is already
# once included in the height of the last block, and I do not know
# why there must be the number 1 at the end... but it works
w.setFixedHeight(h + doc.documentMargin() + 2 * w.frameWidth() + 1)
w.show()
app.exec_()
So this should show the box without scroll bar. If you decrease the height by 1, the scroll bar appears. This should work with any number of lines, document margins, frame widths, formatting etc. Hopefully.
Shot in the dark without testing
Have you looked # pageSize?
From the docs:
This property holds the page size that should be used for laying out the document
The units are determined by the underlying paint device. The size is
measured in logical pixels when painting to the screen, and in points
(1/72 inch) when painting to a printer.
By default, for a newly-created, empty document, this property
contains an undefined size.
If you set the pageSize, as directed by the other thread, I'd expect you'd get the value out in the pixels that QPlainTextEdit::setMinimumHeight needs.
Using Google Maps JavaScript API v3, it is possible to change the zoom of a map using the setZoom method, see the Map class.
I am able to set the zoom to a fractional value and it works, i.e. gmap.setZoom(1.1) works. However, it stops working on the 4th call with a fractionnal zoom, i.e.:
gmap.setZoom(1.1) works
gmap.setZoom(1.2) works
gmap.setZoom(1.3) works
gmap.setZoom(1.4) doesn't work, the map turns grey.
It's not the 1.4 value that doesn't work. Setting 1 then 1.4 does work. It really seems to be on the 4th time that we set a fractionnal value.
Is this a known bug or is there a way to avoid the map to turn grey after multiple zooming using fractionnal zooms?
I'm surprised it works ever. Fractional zoom levels are not supported. From the documentation:
zoom | Type: number
The initial Map zoom level. Required. Valid values: Integers between zero, and up to the supported maximum zoom level.
Related issues in the issue tracker:
Issue 10977: Bug: Zoom cannot be set to e.g. 6.5 initially - map is shown in gray color only
Issue 9948: Fractional zoom level(fine zoom)
I'm currently working on a project where I need to scale the whole UI based on a global scale factor. I have about 2000 Items (and yes, I need that much). For now, those are just simple Rectangle, but the will get more complex later. I simulated the final behavior by adding5 rectangles inside each of the "main rectangles".
The problem is, if I change the scale factor, it takes about 3 seconds until the change is done. In this 3 seconds, the application freezes.
It tried different ways of using the scale:
Direct for all scalable properties:
Rectangle {
width: 50 * global.scale
height: 50 * global.scale
}
Using the scale property:
Rectangle {
width: 50
height: 50
scale: global.scale
}
However, both of them are equally slow. So, is there a way to zoom the whole ui with having to resize every element? Or anything else, that makes it faster?
The answere was quite simple: Using the debug build can be very slow, but as soon as I started a release build, it worked just fine.
I have noticed the following problem when implementing a Word-like application:
The QRasterizer in Qt skips lines when they have a thickness smaller than 1.0f. I am running into this situation when zooming out in my word editor application. The Y values of the two line points then get as small as this:
y1 = 290.32812500000000
y2 = 290.92187500000000
When rendering the line Qt skips it. I have tracked this down to the following code in QRasterizer::rasterize(), where min_y and max_y are the two above Y values times 64 (fixed point values):
int iTopBound = qMax(d->clipRect.top(), int((min_y + 32 + COORD_OFFSET - COORD_ROUNDING) >> 6));
int iBottomBound = qMin(d->clipRect.bottom(), int((max_y - 32 + COORD_OFFSET - COORD_ROUNDING) >> 6));
if (iTopBound > iBottomBound)
return;
Since min_y is rounded upwards and max_y is rounded downwards it runs into the IF condition and thus returns without performing any rendering.
I can workaround this problem by enabling anti-aliasing, which however results in the rendering getting brighter when zooming out. What I really need is a behavior like in Microsoft Word: no matter how far you zoom out, a black rectangle always stays visible as black rectangle on screen.
Using a cosmetic pen would solve the problem but doesn't work together with a customizable line thickness, which I need to support as well.
Any ideas how to workaround this problem?
Greetings,
Fabian
I am developing cocos3d app for iOS.
I added the walk animation for a "Man" blend file. Looks, the man is doing walk animation fine in Blender. I have used the following settings to convert to collada and then pod. I am getting wrong output mentioned like below.
Export .dae options such as "Export Data Options (Apply modifiers, Selection only, Include Armatures are enabled),
Texture options (Include UV Textures, Include Material textures and copy are enabled),
Armature Options (Deform Bones only is enabled),
Collada Options (Use Object Instance enabled)
options enabled in Blender when converting to .dae file.
And then, In PVRGeoPOD 2.13 version,
Export Geometry (Primitive Type: Indexed Triangle list)
Use custom optimisations settings (PVRTGeomterySort sorting method), Vertex data optiomisations (Interleave Vertex data, align vertex data 32 bits)
Vector (Position - float, Normal - float, Color - RGBA)
Export Skinning data ( Bone indices - unsigned byte; Bone weights - unsigned bytes)
Matrix palette size - 11
Export Mapping Channels (uvw0 - float only enabled)
Flip V co-ordinate enabled
Material - 'Export Materials' only enabled
Transformations - Export animations, Index animation data are enabled. Co-ordinate system - OpenGL model space
OUTPUT:
A Man walking animation is happening kind of, but the man is completed black shaded and bones are unlikely expanded. Output is ugly one.
Please note: If i add the same Man without adding "Armature (and bone, walk animation)" in blender and the exported pod is showing the man very well in the device output without any animation.
Output 1: When i added walk animation using armature bones, output is black shaded with improper walk animation. Pls. refer this link to see output
https://www.yousendit.com/download/UVJpWUh0bThiV3dsYzhUQw
Output 2: Output without any animation in that Man pod model. Pls refer this link.
https://www.yousendit.com/download/UVJpWUh0bThoMlhyZHNUQw
I have uploaded the .blend, .pod files attached in this link -> https://www.yousendit.com/download/UVJpWUhndWNsUjk3czlVag
How do i solve the animation issue and provide the smooth walk animation with clear view? As i need to fix this issue urgently, could you please help on suggesting to solve this issue?
thank you.
I have solved it. Here is the solution-> http://www.cocos2d-iphone.org/forum/topic/345818