Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k Topics 77.4k Posts
  • [Solved] Custom QtQuick MessageDialog

    9
    0 Votes
    9 Posts
    6k Views
    C
    few minutes after my previous post, I got a solution/workaround for it. It doesn't work if you define the standardButtons inside the MessageDialog like: @ MessageDialog { id: messageDialogOnRemove modality: Qt.WindowModal // ... other stuff here.. standardButtons: StandardButton.Yes | StandardButton.No }@ but it works if you avoid defining the standardButtons in the declaration above and put it just before you want to display it, like: @messageDialogOnRemove.standardButtons = StandardButton.Yes | StandardButton.No messageDialogOnRemove.show()@ Hope this helps someone.
  • 0 Votes
    1 Posts
    479 Views
    No one has replied
  • Dynamic items adding to the Flow layout?

    12
    0 Votes
    12 Posts
    17k Views
    R
    I am trying to do something similar to this "Jquery Token Input":http://loopj.com/jquery-tokeninput/. So far I have this. @import QtQuick 2.2 Item { width: 400 height: 30 Flow { id: tagContainer anchors.fill: parent anchors.margins: 4 spacing: 4 add: Transition { NumberAnimation { property: "scale"; from: 0.4; to: 1.0; duration: 300; } } TextInput { id: input width: 100 height: parent.height onAccepted: { var component = Qt.createComponent('Tag.qml') var obj = component.createObject(tagContainer, { 'text' : input.text }) } } } } @ Almost similar to your implementation. But when I add the 'Tag' components dynamically to the 'Flow', it keeps on getting appended to the right and it does not get wrapped. I would appreciate any help.
  • QML UI over OpenGL

    2
    0 Votes
    2 Posts
    3k Views
    K
    After some research, I considered 2 ways to achieve the result I want: rendering the OpenGL scene to an FBO, and displaying that below the QML UI Following [url=https://www.youtube.com/watch?v=GYa5DLV6ADQ]this video[/url] by Sean Hammer I followed the 2nd option, and got it working. Now of course, my UI view "steals" all the mouse/touch events, which I'll have to propagate to my OpenGL scene. The only issue remaining is a warning I get when rendering my OpenGL scene: @W/Qt ( 3975): kernel\qobject.cpp:777 (bool check_parent_thread(QObject*, QThreadData*, QThreadData*)): QObject: Cannot create children for a parent that is in a different thread. W/Qt ( 3975): (Parent is RubiksGL(0x6003b3a8), parent's thread is QThread(0x5cb65e48), current thread is QSGRenderThread(0x5cb39758)@ I made sure that I added Qt::DirectionConnection to my connection between the beforeRendering() signal and the rendering slot, so I'm not sure where the threads are different. The only thing I know is it happens inside my OpenGL rendering function, which looks like this: @void RubiksGL::render() { m_funcs->glViewport(0, 0, width(), height()); m_funcs->glDepthMask(true); m_funcs->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); m_program->bind(); moveCamera(); computeViewProjectionMatrices(); drawObjects(); m_program->release(); }@ drawObjects does the following: @Object *object; QMatrix4x4 matrix; QOpenGLVertexArrayObject *vao; for (int i=0; i<m_objectsList.size(); i++) { object = m_objectsList.at(i); matrix = m_VPMatrix * object->transform(); m_program->setUniformValue(m_matrixUniform, matrix); vao = new QOpenGLVertexArrayObject(this); vao->create(); vao->bind(); std::vector<QVector3D> vertices = object->vertices(); std::vector<QVector3D> colors = object->colors(); m_verticesVBO.bind(); m_verticesVBO.allocate(&vertices[0], vertices.size() * sizeof(QVector3D)); m_colorsVBO.bind(); m_colorsVBO.allocate(&colors[0], colors.size() * sizeof(QVector3D)); m_funcs->glEnableVertexAttribArray(0); m_verticesVBO.bind(); m_funcs->glVertexAttribPointer(m_posAttr, 3, GL_FLOAT, GL_FALSE, 0, NULL); m_funcs->glEnableVertexAttribArray(1); m_colorsVBO.bind(); m_funcs->glVertexAttribPointer(m_colAttr, 3, GL_FLOAT, GL_FALSE, 0, NULL); m_funcs->glDrawArrays(GL_TRIANGLES, 0, vertices.size()); m_funcs->glDisableVertexAttribArray(1); m_funcs->glDisableVertexAttribArray(0); m_verticesVBO.release(); m_colorsVBO.release(); vao->release(); delete vao; }@ I know my usage of VAOs and VBOs is not correct (I should move them to my initialize() function), that is something I'll fix later. The warning above is issued for each glDrawArrays call. Is there something I missed regarding threads, either between the QQuickView and OpenGL, or directly within my rendering function?
  • popup on click for a TableView itemDelegate

    1
    0 Votes
    1 Posts
    838 Views
    No one has replied
  • Qml delay function problem

    3
    0 Votes
    3 Posts
    1k Views
    C
    Or you can setup SequentialAnimation with your animation and ScriptAction with given script
  • Problem with VideoOutput

    3
    0 Votes
    3 Posts
    847 Views
    P
    The problem is that I've tried to use this property like in this thread: http://qt-project.org/forums/viewthread/27741 but I used QObject based class instead of QMediaPlayer . Sadly, it didn't work. Maybe it's possible to directly deliver QVideoFrame to some QML type although I didn't find anything about it
  • Image masks alternative for QML items

    9
    0 Votes
    9 Posts
    4k Views
    T
    It should be blended with moving rectangle and displayed only when rectangle on the top. Like this !http://i.stack.imgur.com/YUs82.png(combine effects)!
  • SOLVED: Comparing line edit to a specific phrase

    3
    0 Votes
    3 Posts
    732 Views
    C
    Yes it works! Thank you!!
  • SOLVED: URGENT!! Help with QT

    6
    0 Votes
    6 Posts
    2k Views
    C
    Ok, i shall do that. Thank you for your help!
  • Access QObject Item from a QList

    4
    0 Votes
    4 Posts
    1k Views
    M
    [quote author="Zlatomir" date="1405190039"]You need to cast the pointer to the correct type, recommended ways are: dynamic_cast or (because you have a QObject) "qobject_cast":http://qt-project.org/doc/qt-5/qobject.html#qobject_cast: @ Champions* item2 = qobject_cast<Champions*>(datalist.at(2)); if(item2) item2->name(); @ [/quote] Thanks a lot ! It works well for me !
  • How to set dashed border in QML?

    3
    0 Votes
    3 Posts
    5k Views
    M
    i think it is possible with CSS, but i don't know the way.. btw, thanks
  • Qml problem with font size

    4
    0 Votes
    4 Posts
    2k Views
    G
    switching to pointSize do not help, the same problem !https://lh3.googleusercontent.com/-bv71O37AKeo/U8Iwagd8XJI/AAAAAAAAG_Q/wdfXHMnbnBg/w549-h878-no/Screenshot_2014-06-27-18-20-56.png(qml problem)!
  • Different OS's, different font sizes?

    4
    0 Votes
    4 Posts
    10k Views
    T
    Point sizes are device-independent. A 16pt font should theoretically be the same size no matter what device you're on or what the density of the screen is, assuming that the vendor of the display follows "VESA standards":http://en.wikipedia.org/wiki/Extended_display_identification_data. You can use JavaScript expressions in QML to achieve a percent value. For example: @font.pixelSize: parent.width * 0.9@ That's 90% of the parent.width. Figure out what you want 90% of, then multiply by 0.9. ;)
  • How to access a root context from QObject?

    3
    0 Votes
    3 Posts
    2k Views
    C
    Here's the full answer to the question. Inside your QObject derived subclass, you can do the following: @ // get rootContext() and required contextProperty as QVariant QVariant myobject_v = qmlEngine(this)->rootContext()->contextProperty("myname"); // cast QVariant first to QObject* and then to my desired ObjectClass* ObjectClass myobject = qobject_cast<ObjectClass>(qvariant_cast<QObject*>(myobject_v)); @ http://stackoverflow.com/a/3918893/532513 showed how to cast from QVariant to ObjectClass*, the rest was found through snippets of documentation scattered all over the place. :|
  • Javascript assignment destroys property binding

    11
    0 Votes
    11 Posts
    3k Views
    JKSHJ
    [quote author="flobe" date="1405152382"]Well, I'm looking for a reusable toggle button component which state (on or off) can be controlled by a mouse click (which results in - as far as I see - a Javascript assignment) as well as from a state property of another QML item. ... I have just checked the CheckBox implementation of QtQuick.Controls which show the same problem. It is not possible to keep two CheckBox items in sync by using property bindings.[/quote]I think that makes sense. A CheckBox and ToggleButton have a boolean property. Usually, the mouse controls that property. If you bind that property to an external boolean variable, then the external variable will also try to control that property. You now have two different and unsynchronized things trying to write to that property -- this can create conflicts, as you've discovered. I think your onStatusChanged solution is the only way to achieve what you want.
  • [SOLVED]Adding Tab in existing TabView from C++ side

    4
    0 Votes
    4 Posts
    3k Views
    M
    To pass component, pass pointer to QQmlComponent inside fromValue(), as follows... @ QObject* m_pTabView = findChild<QQuickItem >("myTabView"); if (m_pTabView) { QVariant returnedValue; QVariant title = "Hello"; QQmlComponent component = new QQmlComponent(&app.qmlEngine(), QUrl("qrc:/qml/Measurements.qml"), this); QMetaObject::invokeMethod(m_pTabView, "addTab", Q_RETURN_ARG(QVariant, returnedValue), Q_ARG(QVariant, title), Q_ARG(QVariant, QVariant::fromValue(component))); } @
  • [SOLVED] Local storage working on Desktop but not in Android

    11
    0 Votes
    11 Posts
    2k Views
    p3c0P
    That's great. It was a good effort from you. You can mark the thread as solved by editing the thread title and prepend [solved] so that other's may know that this thread has a possible solution.
  • How do I specify an absolute URL for a javascript import?

    2
    0 Votes
    2 Posts
    895 Views
    dheerendraD
    you can try importing like import "../../../../utils1.js" if qml and js are in drive.
  • Howto add a button to a TableView header column

    2
    0 Votes
    2 Posts
    2k Views
    p3c0P
    Hi, Yes that's possible. Check "headerDelegate":http://qt-project.org/doc/qt-5/qml-qtquick-controls-tableview.html#headerDelegate-prop. You will need to create a Button Component and assign to it.