Skip to content

Qt Development

Everything development. From desktop and mobile to cloud. Games, tools, 3rd party libraries. Everything.
144.6k Topics 724.6k Posts
Qt 6.11 is out! See what's new in the release blog

Subcategories


  • This is where all the desktop OS and general Qt questions belong.
    84k 460k
    84k Topics
    460k Posts
    Pl45m4P
    @sales99 Beside m_memberVar there is also _memberVar mMemberVar and more variants... which are a matter of taste. At least one of them should be picked to differ between class member and local scope variables
  • Looking for The Bling Thing(tm)? Post here!
    20k 78k
    20k Topics
    78k Posts
    S
    Hi, I'm investigating how to draw hundreds of QML items very fast. I subclassed QQuickItem and create my own QSGNodes with geometry and material in its updatePaintNode() function. My test consist of 1000 items, each with two random sized circles with random colors: [image: b7e99ac0-0796-4717-ac58-08ada6d9ee99.jpg] All circles move contineously. I'm using 2 nodes in the scene graph. One for each circle. In my first version I used a QSGFlatColorMaterial for each item/circle, each with an other color. So I expected this to be slow because drawcalls can not be batched. When enabling the feature to show the batching this is confirmed: [image: 4d915503-94f9-496f-b92e-8f0f1c442957.jpg] Each color is a separate batch. When enabling rendering info it says: Renderer::render() QSGAbstractRenderer(0x1a8dec6aef0) "rebuild: none" Rendering: -> Opaque: 2000 nodes in 680 batches... -> Alpha: 0 nodes in 0 batches... - 0x1a8d95a7860 [ upload] [noclip] [opaque] [ merged] Nodes: 3 Vertices: 3072 Indices: 3078 root: 0x0 - 0x1a8d95a8c60 [ upload] [noclip] [opaque] [ merged] Nodes: 5 Vertices: 5120 Indices: 5130 root: 0x0 - 0x1a8d95a8120 [ upload] [noclip] [opaque] [ merged] Nodes: 4 Vertices: 4096 Indices: 4104 root: 0x0 ... Some batching seems to happen, but a lot of drawcalls. So I switched to the QSGVertexColorMaterial so that I could give all items and circles the same material. When enabling the feature to show the batching again: [image: fd1d4425-e3c8-4486-8a8f-2c2b8eb5f5c1.jpg] So it seems all is drawn in one batch! which is confirmed using the render info: Renderer::render() QSGAbstractRenderer(0x2354aaaf0c0) "rebuild: none" VSync 19 ( 40.4986ms ) Rendering: -> Opaque: 2000 nodes in 1 batches... -> Alpha: 0 nodes in 0 batches... - 0x2350540ab20 [ upload] [noclip] [opaque] [ merged] Nodes: 2000 Vertices: 2048000 Indices: 2052000 root: 0x0 sets: 32 -> times: build: 0, prepare(opaque/alpha): 0/0, sorting: 0, upload(opaque/alpha): 13/0, record rendering: 0 But the strange thing is that the render time for the first one is about 37 ms. While for the fully batched one it is 40 ms. In stead of much faster it is even slightly slower! How is this possible? People always say that the number of drawcalls is often the problem with slow rendering. This is updatePaintNode of the first version: QSGNode *MyQuickItem::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*) { QSGNode* parentNode = oldNode; QSGGeometryNode *node; QSGGeometry *geometry; const int segments = 1024; const int vertexCount = segments; if (!parentNode) { parentNode = new QSGNode; // Circle 1 Node Setup QSGGeometryNode* node1 = new QSGGeometryNode; node1->setGeometry(new QSGGeometry(QSGGeometry::defaultAttributes_Point2D(), vertexCount)); node1->geometry()->setDrawingMode(QSGGeometry::DrawTriangleStrip); QSGFlatColorMaterial* material1 = new QSGFlatColorMaterial; material1->setColor(m_dialColor); node1->setMaterial(material1); node1->setFlag(QSGNode::OwnsGeometry); node1->setFlag(QSGNode::OwnsMaterial); parentNode->appendChildNode(node1); // Circle 2 Node Setup QSGGeometryNode* node2 = new QSGGeometryNode; node2->setGeometry(new QSGGeometry(QSGGeometry::defaultAttributes_Point2D(), vertexCount)); node2->geometry()->setDrawingMode(QSGGeometry::DrawTriangleStrip); QSGFlatColorMaterial* material2 = new QSGFlatColorMaterial; material2->setColor(m_indicatorColor); node2->setMaterial(material2); node2->setFlag(QSGNode::OwnsGeometry); node2->setFlag(QSGNode::OwnsMaterial); parentNode->appendChildNode(node2); } // Fetch our nodes QSGGeometryNode* c1Node = static_cast<QSGGeometryNode*>(parentNode->childAtIndex(0)); QSGGeometryNode* c2Node = static_cast<QSGGeometryNode*>(parentNode->childAtIndex(1)); // Circle 1: Left side QSGGeometry::Point2D* vertices1 = c1Node->geometry()->vertexDataAsPoint2D(); addCircleGeometry(vertices1, 0, m_dialRadius * 1.1f +mPosDelta, m_dialRadius * 1.1f +mPosDelta, m_dialRadius, m_dialColor, segments); // Circle 2: Right side QSGGeometry::Point2D* vertices2 = c2Node->geometry()->vertexDataAsPoint2D(); addCircleGeometry(vertices2, 0, m_dialRadius * 1.9f -mPosDelta, m_dialRadius * 1.9f -mPosDelta, m_dialRadius, m_indicatorColor, segments); c1Node->markDirty(QSGNode::DirtyGeometry); c2Node->markDirty(QSGNode::DirtyGeometry); return parentNode; } This is updatePaintNode of the second version: QSGNode *MyQuickItem::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*) { QSGNode* parentNode = oldNode; QSGGeometryNode *node; QSGGeometry *geometry; const int segments = 1024; const int vertexCount = segments; if (!parentNode) { parentNode = new QSGNode; // Circle 1 Node Setup QSGGeometryNode* node1 = new QSGGeometryNode; node1->setGeometry(new QSGGeometry(QSGGeometry::defaultAttributes_ColoredPoint2D(), vertexCount)); node1->geometry()->setDrawingMode(QSGGeometry::DrawTriangleStrip); QSGVertexColorMaterial* material1 = new QSGVertexColorMaterial; // Shared material type enables batching! material1->setFlag(QSGMaterial::Blending, false); node1->setMaterial(material1); node1->setFlag(QSGNode::OwnsGeometry); node1->setFlag(QSGNode::OwnsMaterial); parentNode->appendChildNode(node1); // Circle 2 Node Setup QSGGeometryNode* node2 = new QSGGeometryNode; node2->setGeometry(new QSGGeometry(QSGGeometry::defaultAttributes_ColoredPoint2D(), vertexCount)); node2->geometry()->setDrawingMode(QSGGeometry::DrawTriangleStrip); QSGVertexColorMaterial* material2 = new QSGVertexColorMaterial; // Shared material type enables batching! material2->setFlag(QSGMaterial::Blending, false); node2->setMaterial(material2); node2->setFlag(QSGNode::OwnsGeometry); node2->setFlag(QSGNode::OwnsMaterial); parentNode->appendChildNode(node2); } // Fetch our nodes QSGGeometryNode* c1Node = static_cast<QSGGeometryNode*>(parentNode->childAtIndex(0)); QSGGeometryNode* c2Node = static_cast<QSGGeometryNode*>(parentNode->childAtIndex(1)); // Circle 1: Left side QSGGeometry::ColoredPoint2D* vertices1 = c1Node->geometry()->vertexDataAsColoredPoint2D(); addCircleGeometry(vertices1, 0, m_dialRadius * 1.1f +mPosDelta, m_dialRadius * 1.1f +mPosDelta, m_dialRadius, m_dialColor, segments); // Circle 2: Right side QSGGeometry::ColoredPoint2D* vertices2 = c2Node->geometry()->vertexDataAsColoredPoint2D(); addCircleGeometry(vertices2, 0, m_dialRadius * 1.9f -mPosDelta, m_dialRadius * 1.9f -mPosDelta, m_dialRadius, m_indicatorColor, segments); c1Node->markDirty(QSGNode::DirtyGeometry); c2Node->markDirty(QSGNode::DirtyGeometry); return parentNode; }
  • The forum for developing everything embedded: Linux, WinCE, Symbian, MeeGo... you name it.
    14k 63k
    14k Topics
    63k Posts
    ekkescornerE
    similar issue for me on macOS JDK 21 Qt 6.11.1 with included QtC 20.0 and Tools downloaded using QtC tools contained cmdline-tools 20.0 all works perfect Qt 6.12 Beta 3 with included QtC 20.0.1 tools contained cmdline-tools 23.0 error: packages not found selecting tools w cmdline-tools 20.0: no errors so I have a workaround for now - but should be fixed so I opened issue https://qt-project.atlassian.net/browse/QTCREATORBUG-34905 Edit: THX to AI found out: with cmdline-tools 23, SDKManager is deprecated and replaced by Android CLI. Probably we have to wait until QtCreator supports Android CLI and in the meantime using cmdline-tools < 23
  • This is a discussion space for

    • for audio / video playback and recording
    • media formats and codecs
    • camera and screen sharing functionality
    52 226
    52 Topics
    226 Posts
    T
    @Nils-Petter-Skalerud i'm aware of this ! that's why i needed to know if there's a known fix or an export maybe that resolve this without touching the qt code or at least my qml code to make it work. I'll be waiting for your respond ! i hope you'll not forget to ask the expert, this can really help me :') thank you !!
  • Have a question about Qt Creator, our cross-platform IDE, or any of the other tools? Ask here!
    8k 37k
    8k Topics
    37k Posts
    cristian-adamC
    @Asperamanca https://codereview.qt-project.org/c/qt-creator/qt-creator/+/754371 fixes the issue. Do try it out when you have the chance! Thanks.
  • Your Qt just doesn't want to build? Your compiler can't find the libs? Here's where you find comfort and understanding. And help.
    10k 52k
    10k Topics
    52k Posts
    SGaistS
    Hi and welcome to devnet, From the phrasing, it seems you have a commercial license. In that case, you should contact the Qt Company directly. This forum is more user oriented.
  • What can we say - we like games. And you can use Qt to write some. Questions? Ask here.
    875 4k
    875 Topics
    4k Posts
    K
    Hello Folks! I was upgrading to Qt 6.8 and tried to load my Object File within the QML File. The Mesh gets loaded, positioned and scaled properly, but is white. I need to apply custom colors to the meshes. This is how i got so far: NOTE: This is not working. Any approach to colorize the Model fails: RuntimeLoader { id: loader source: "Resources/fem_3.obj" position: Qt.vector3d(0,1,0) scale: Qt.vector3d(5,5,5) function applyMaterialToAllModels(node, material) { if (typeof node === "undefined") return; if (node instanceof Model) { node.material = material; } else { // console.log("node type: " + typeof node); } if (typeof node.children === "undefined") return; for (var i = 0; i < node.children.length; i++) { applyMaterialToAllModels(node.children[i], material) } } onStatusChanged: { if (loader.status === RuntimeLoader.Success) { console.log("success loading asset file.") var material3 = Qt.createQmlObject( "import QtQuick3D\n" + "DefaultMaterial {\n" + " diffuseColor: \"red\"\n" + "}", loader); material3.diffuseColor = "red"; applyMaterialToAllModels(loader, material3); } } } Can you help me? What did I miss in the transition from Qt3D to QtQuick3D ? best regards, kevin_d
  • Discussions and questions on QtWebEngine
    1k 4k
    1k Topics
    4k Posts
    J
    Finally got my 6.11 installation working. This was fixed in the update.
  • You're using Qt with other languages than C++, eh? Post here!
    870 3k
    870 Topics
    3k Posts
    PedromixP
    New version QtJambi 6.11.1 is available now πŸŽ‰. For all who want to create smart UIsπŸš€ in Java or Kotlin based upon the latest Qt release. https://www.qtjambi.io/ [image: 95a6c11a-f7b2-4a9c-8325-ccfc9c93b3ec.png]
  • For discussion and questions about Qt for Python (PySide & Shiboken)

    3k 15k
    3k Topics
    15k Posts
    J
    @JonB Thanks for the detailed response. I'm using the .ui file approach only while I learn Qt and prototype my application, and will switch to generating code once the user interface is stable. There's a lot to digest in your response and I'll follow up on your reading suggestions. Clearly there's still a lot wrong in my mental model of how things work. For example, since my last post I have whittled things down to this: def __init__(self): super().__init__() loader = QUiLoader() ui_file = QFile("../../../qtTest/test.ui") if not ui_file.open(QFile.ReadOnly): print("Cannot open ui file") sys.exit(-1) self.ui = loader.load(ui_file) ui_file.close() layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.ui) self.setLayout(layout) self.setWindowTitle("My Qt Designer App") This works and produces the minimum-size window from my previous post. Notice however self.ui = loader.load(ui_file), where don't specify the parent widget. If I change the code to self.ui = loader.load(ui_file, self) then the code hangs at app.exec() with no window displayed.
  • Specific issues when using Qt for WebAssembly

    468 2k
    468 Topics
    2k Posts
    Nils SjobergN
    Try an unoptimized build first (without optimizations) to verify a code folding/LTO issue, and if so, update emsdk to a newer version; if you don't feel like messing with it, moving the file is the quick fix.
  • Discussions and questions about Qt Quick Ultralite and using Qt on microcontrollers in general

    156 476
    156 Topics
    476 Posts
    G
    I am working on a Qt for MCUs application and currently using OTF font files with the Static font engine. The font quality is good with OTF, but internal flash usage becomes very high. When I use FMP fonts, flash usage is low, but some glyphs do not render properly. Any guidance on the correct approach to move OTF font storage to external memory would be very helpful. Thank you.
  • Combining Qt with 3rd party libraries or components? Ask here!
    1k 6k
    1k Topics
    6k Posts
    S
    I know this is an old thread, but since it still shows up in search results: In case someone has issue with cross-compiling vlc4.0 from linux to windows, You can also checkout a blog on this issue: https://medium.com/@skdevane/building-vlc-4-0-for-windows-inside-wsl2-every-wall-i-hit-and-how-i-got-through-them-72e6e1e2d456
  • The forum for discussing the Qt Digital Advertising Platform

    16 41
    16 Topics
    41 Posts
    E
    @nayka Can I use QtDigitalAdvertising on PC applications? Or is it only allowed for use on Android or iOS mobile devices?
  • For discussion and questions about Qt Insight

    11 20
    11 Topics
    20 Posts
    jsulmJ
    @Alejandro_qt_ Here is an example how to build qtbase module: https://stackoverflow.com/questions/50022325/building-qt-module-from-source