Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k Topics 77.4k Posts
  • [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.
  • Moving Pages using Listview with viewTransition

    6
    0 Votes
    6 Posts
    2k Views
    B
    Hi, I came across pathview..i am trying to get output...will update soon wen completed
  • [solved] Z-order in dynamically created object

    10
    0 Votes
    10 Posts
    4k Views
    p3c0P
    Also another observation, keeping ApplicationWindow if you set the z value of Rect to negative also works as expected.
  • GridLayout rowSpan bug

    1
    0 Votes
    1 Posts
    628 Views
    No one has replied
  • 0 Votes
    7 Posts
    5k Views
    sierdzioS
    That is all really cool, thanks for sharing!
  • Linking error: cannot find -lGL

    3
    0 Votes
    3 Posts
    2k Views
    W
    oh. thanks.
  • How to deal with the "time" basic type?

    9
    0 Votes
    9 Posts
    5k Views
    X
    You are very kind. thank you for your time ! :D
  • Alphabetical index in ListView

    1
    0 Votes
    1 Posts
    700 Views
    No one has replied
  • Focus policy

    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • Changing element property while being flicked

    2
    0 Votes
    2 Posts
    537 Views
    p3c0P
    Hi, Just another suggestion, would PathView be suitable to you requirement ? Check "PathView":http://qt-project.org/doc/qt-5/qml-qtquick-pathview.html docs. There's "PathAttribute":http://qt-project.org/doc/qt-5/qml-qtquick-pathattribute.html object which can be used to set Opacity or Scale etc.. Once used the corresponding properties are set properly as per the Item's position in the List. Check the example in it's description. With PathView you can simulate a Simple ListView or other Complex paths by setting the proper Path like PathQuad, PathLine etc..
  • Code examples - statemachine using Qt Quick and C++

    7
    0 Votes
    7 Posts
    6k Views
    R
    [quote author="andreyc" date="1404932898"]Thank you for the sample project. I tried to build it and got the errors: @ WARNING: Failure to find: qml.qrc /home/achichinov/Qt5.3.1/5.3/gcc_64/bin/rcc: File does not exist 'qml.qrc' @ Do I need to create it or you missed it in your submit?[/quote] Thanks. I forgot that it doesn't add those by default. I've added it to source control and it's out there now.
  • [SOLVED] Load Component on signal

    5
    0 Votes
    5 Posts
    1k Views
    M
    Tanks :)
  • Center GridView Rows on screen

    3
    0 Votes
    3 Posts
    1k Views
    D
    Hi p3cO, Normally, anchors.centerIn would do the job but there may be a situation where the GridView is not filled with items all the way to the edge of its container (depending on number of items available or differences in available screen width). In that case centering the GridView does not actually center the items contained therein. I was hoping the GridView implementer's would have found a nice solution for that. Turns out, I think I will have to use a little math and determine what the actual combined width of the items will amount to for a single row of the grid and then set the width of the GridView to that before centering. If anyone has a more elegant solution I would be glad to hear it. thanks BD
  • How to determine the number of items per row in GridView

    3
    0 Votes
    3 Posts
    3k Views
    D
    Okay, thanks.
  • QML Text Element background-color support for divs

    3
    0 Votes
    3 Posts
    1k Views
    P
    Ah thanks man. :) Did not know that bug page existed. Will reference it in the future.
  • [solved] Center Text with letterSpacing

    8
    0 Votes
    8 Posts
    2k Views
    H
    Adding one space at the beginnig of the text solves it. Visually it looks centered.
  • 0 Votes
    4 Posts
    6k Views
    A
    Hi, I have searched for many solutions (including the one proposed by Dheerendra). However, most of them worked only while using local files (not resource files inside the binary program). Finally, I came up with a very easy solution: C++ code (in main.cpp or where you load the QML interface): @ int main(int argc, char *argv[]) { // Initialization code here (& other tasks) QApplication app(argc, argv); // Create a QDir that points out to your path in the resources folder QDir directory(":/my_qrc_images_prefix/"); // Load all files with the *.PNG extension // (you can modify this to suit your needs. QStringList imagesList = directory.entryList(QStringList("*.png")); // Now load the QML interface (at least I do it in this way) QQmlEngine* engine = new QQmlEngine(); QQmlComponent* component = new QQmlComponent(engine); // Allow the QML interface to access the imagesList as a list model engine->rootContext()->setContextProperty("imageModel",QVariant::fromValue(imagesList)); // Load the window and execute the app QQuickWindow* window = qobject_cast<QQuickWindow*>(component->create()); return app.exec&#40;&#41;; } @ QML code @ import QtQuick 1.0 // Create the root item Item { // Set the size of the item width: 200 height: 250 // Create the list view with the images ListView { anchors.fill: parent // We use as a model with QStringList used // in the initialization of the QML interface. model: imageModel // Represent the data of the model in an image delegate: Image { // Load the image (modelData represents the current image) // Note that in my case I needed to add the full path // of the image in order to make it work. source: "qrc:/my_qrc_images_prefix/" + modelData } } } @ So, in summary you basically you create a QList in C++ and load it in the QML interface. However, the QList is based on a data that the QDir class gives to us. However, its important to only use ":/" instead of "qrc:/" while working with QDir. This implementation can be modified to load local files (using the "file://" prefix in the QML image). Thanks to all who helped me solve this problem! Greetings!