Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.1k Topics 77.6k Posts
  • Resolution independent gui

    9
    0 Votes
    9 Posts
    6k Views
    O
    Hello, certainly there is a very good way on how to create an resolution independent gui using for example the metric system and centimeters. You will have to import QtQuick.Window. @import QtQuick 2.2 import QtQuick.Window 2.0@ Then you can just ask the class Screen for the pixelDensity of our screen: @function cm(cm) { return cmScreen.pixelDensity10 }@ If we access the function that way: "... width: cm(1)", then the width will be 1 centimeter wide.
  • 0 Votes
    2 Posts
    2k Views
    B
    I found out that it is possible (and easy) to directly pass a component created in C++ to QML. So right now, I modified the code pretty much like this: @ WindowManager::prepareNewView(int stuffId) { MyDatabase db; // Getting something to show in QML from somewhere based on the parameter received SomeStuff stuff = db.getStuff(stuffId) // Creating the new context, based on the global one QQmlContext *context = new QQmlContext(this->rootContext()); // Exposing the object I need to show in QML to the new context context ->setContextProperty("someStuff", stuff); // Creating the component QQmlComponent component(this->engine(), QUrl("qrc:/qml/MyComponent.qml")); // Creating the istance of the new component using the new context QQuickItem *newView = qobject_cast<QQuickItem*>(component.create(context)); // Getting the root component (the Rectangle with it mainWindow) QObject *object = this->rootObject(); // Manually setting the new component as a child of mainWIndow newView->setParentItem(qobject_cast<QQuickItem*>(object)); // Invoking the QML that will connect the events of the new window, while passing the component created above as QVariant QMetaObject::invokeMethod(object, "addView", Q_ARG(QVariant, QVariant::fromValue(newView))); } @ In QML the function in the main.qml is now like this: @ // Function called from C++; the param "newView" is the last component added function addView(newView) { // ... Here I would use the new view to connect signals to slots and such as if I created "newView" directly in QML } @ So I managed not to change the code too much after all.
  • Add image slider in Qt Quick

    1
    0 Votes
    1 Posts
    693 Views
    No one has replied
  • How to Color an Image

    8
    0 Votes
    8 Posts
    2k Views
    E
    Thank you all.I Solved it by registering QGraphicsColorizeEffect and applying effect for QML Image.
  • Help me to make an Animation :-(

    1
    0 Votes
    1 Posts
    444 Views
    No one has replied
  • [SOLVED] How to get path to photo gallery

    3
    0 Votes
    3 Posts
    997 Views
    J
    Well, the pure QML may not help you in any way, I am looking for solutions too. As an alternate, QStandardPaths::standardLocations(QStandardPaths::PicturesLocation); sounds good.
  • Emitting signal from different thread causes QML to crash

    2
    0 Votes
    2 Posts
    2k Views
    K
    Hi, I answer to that old thread because I have the exact same issue with Qt 5.2.1 and Qt 5.3 RC. Is it possible to use Connections to connect a C++ signal from a non-main thread to a QML slot ? The error I get is @QObject::setParent: Cannot set parent, new parent is in a different thread@
  • [SOLVED] QtQuick2ControlsApplicationViewer connect signal to slot

    3
    0 Votes
    3 Posts
    2k Views
    H
    Thanks! I just did what you said. Installed Qt Creator 3.1 and used the engine class. Works perfect! I also manually transfered all data from my old projekt into a new one. Just saw that some new files will be added to the project if you create a new project within Qt Creator 3.1. "qtquick2controlsapplicationviewer" was replaced with "deployment" folder and the qml-files(quick2) will be added to the resources folder instead of the QML folder.
  • Image mask particle system differs

    3
    0 Votes
    3 Posts
    898 Views
    p3c0P
    Hi, I tested your code on Ubuntu 14.04 with Qt 5.2.1 and it works as desired. What is your development environment ? !http://i59.tinypic.com/2hdyy9w.png(Output)!
  • List Model elements from Qt to QML

    1
    0 Votes
    1 Posts
    431 Views
    No one has replied
  • Link Slider and TextInput values together

    1
    0 Votes
    1 Posts
    756 Views
    No one has replied
  • Render QML element as bitmap

    10
    0 Votes
    10 Posts
    4k Views
    T
    Yes! Maybe I will use some tricks to do that. If I have any problem I will ask you. Thank you so much :)
  • Enums not working or be referenced correctly in QML

    8
    0 Votes
    8 Posts
    5k Views
    X
    QML ist mostly "just" JavaScript, and JS has dynamic objects. so the code is valid if you try something like this: @ var obj = {} // empty object console.log(obj.foo) @ obj.foo is valid code, it will just be undefined and that is why your code shows no warnings or error, you just try accessing a property that is not there and Qt will convert "undefined" to 0 if the target type in c++ is an int :)
  • 0 Votes
    2 Posts
    1k Views
    G
    Fail was here... @QQuickView *view = new QQuickView; view->rootContext()->setContextProperty("translation", (QObject *)&translation_obj); view->rootContext()->setContextProperty("json", (QObject *)&file_obj); // Moved up this line... :D view->setSource(QStringLiteral("qml/Main.qml")); view->show();@ Now everything works fine ;)
  • QML serialization for saving whatever on the image

    4
    0 Votes
    4 Posts
    1k Views
    T
    For saving QML element into image, I still don't know how to do it with QT >5.0 any guide I have read are for 4.8. If you know that, you can share it
  • How to Using tableView model in C++ code with UI in QML

    13
    0 Votes
    13 Posts
    5k Views
    ?
    [quote author="Andre" date="1399887061"]No, you'll have to do your own debugging. This forum does not provide a free debugging service.[/quote] Thank you for helping I try to solve it.
  • How to pack the c++ data into QVariant Object list

    4
    0 Votes
    4 Posts
    1k Views
    shavS
    Hi, You can use code like this: @ QVariant getVaraintObect() //This method must have prototype with Q_INVOKABLE macros in you C++ class. { QVariantMap map; map["key1"] = list; //your QVariantList object with items. map["key2"] = 20; //your int value. //.... return QVariant(map); //The method return QVariant object. } @ In QML you call the method of your class which must to return to you your QVaraint object, for example: @ Text { text: yourCPPObject.getVaraintObect().key2. } @ In result you must see 20 in Text element of your QML file. Also you can use console.log to print all structure of object: @ console.log(yourCPPObject.getVaraintObect()); @ In result you must must see something like this: @ {"key1": [], "key2": 20} @
  • QML Binding is inversed

    3
    0 Votes
    3 Posts
    1k Views
    C
    Property declarations in QML are declarative, not imperative. There is no (explicit or implied) ordering of when declarations will be resolved by the engine. If you do need such guarantees, then you should instead call an imperative init() function which sets those properties in the order you expect. Note that the engine implementation may change (to achieve better optimization, for example) in a subsequent patch release which might change the order in which those declarations are resolved, which would "break" your code, so your workaround is a dangerous one. Cheers, Chris.
  • How to show swf file in webview!

    2
    0 Votes
    2 Posts
    2k Views
    E
    the file's location, where is? try it with the file path
  • How to set individual combo boxes currentindex?

    4
    0 Votes
    4 Posts
    1k Views
    G
    Thanks for your suggestion and reply!!