Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k Topics 77.3k Posts
  • 0 Votes
    1 Posts
    723 Views
    No one has replied
  • Create and Control a QML Component from C++

    2
    0 Votes
    2 Posts
    2k Views
    D
    This is how I did it, please go through it and suggest any changes or different approaches for doing the same. @QtQuick2ApplicationViewer *viewer = QtQuick2ApplicationViewer::instance(); QQmlContext *context = viewer->rootContext(); context->setContextProperty("_client", &client); /Main QML File/ viewer->setMainQmlFile(QStringLiteral("qml/qml-dynamic/main.qml")); viewer->showExpanded(); QQmlEngine *engine = viewer->engine(); /dynamically loaded component/ QQmlComponent component(engine, QUrl::fromLocalFile("qml/qml-dynamic/dyn-comp.qml")); QObject *object = component.create(); QQuickItem item = qobject_cast<QQuickItem>(object); /In qml, items won't get drawn unless they are parented to the view./ /* You should always use QObject::setProperty(), QDeclarativeProperty or QMetaProperty::write() to change a QML property value, to ensure the QML engine is made aware of the property change. / object->setProperty("parent", QVariant::fromValue<QObject>(viewer->rootObject())); /This works same as setProperty/ // QQmlProperty::write(object, "parent" // , QVariant::fromValue<QObject*>(viewer->rootObject())); QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership); /Set X and Y properties of the item created./ item->setx(150); item->setY(150);@
  • QML dropdown list/combobox-like in tableview , z-ordering of items

    5
    0 Votes
    5 Posts
    7k Views
    G
    OK,I have found the problem. I can't change the parent in Component.onCompleted.I need to change it in MouseArea's onClicked signal which I want to popup the dropdown list. @ MouseArea { width: 400 height: 30 anchors.bottomMargin: 0 anchors.fill: parent; hoverEnabled: true onClicked: { combo.state = combo.state==="dropDown"?"":"dropDown" // Reparent the dropDown to the top-level item so that it always stays on top of all other items var topLevel = dropDown while(topLevel.parent) { topLevel = topLevel.parent } var coordinates = dropDown.mapToItem(topLevel, 0, 0) dropDown.parent = topLevel dropDown.x = coordinates.x dropDown.y = coordinates.y } }@
  • Loading a another view fro list items

    1
    0 Votes
    1 Posts
    483 Views
    No one has replied
  • Bug when using Loader in a directly instantiated QQuickView

    2
    0 Votes
    2 Posts
    681 Views
    GianlucaG
    File a bug report on http://bugreports.qt-project.org/
  • Converting object to string

    8
    0 Votes
    8 Posts
    15k Views
    L
    Happened here too. Probably you should submit a bug report. Doesn't happen to cpp exported object or js object
  • ComboBox not draw on core profile?

    1
    0 Votes
    1 Posts
    471 Views
    No one has replied
  • [solved] Dynamically adding items

    3
    0 Votes
    3 Posts
    870 Views
    D
    Oops, you're right! The status is 3 (Component.Error), and the errorString showed there was an error in the qml file I was trying to load. Thanks for the hint!
  • QtQuickItem with custom opengl draw - after first frame, item dissapear

    3
    0 Votes
    3 Posts
    1k Views
    K
    pleas Qt guys, does anyone know where is problem?
  • [SOLVED] QML ScreenSaver element in Qt 5.x?

    9
    0 Votes
    9 Posts
    5k Views
    A
    Fo screensaver I had to go down in java.
  • Rectangle as a root error in QtQuick project

    4
    0 Votes
    4 Posts
    2k Views
    JKSHJ
    You're welcome :) [quote author="freddy311082" date="1401503871"]when is it better use QQmlApplicationEngine and QQuickView ??[/quote]If you want a top-level QML window that has a menubar, statusbar and/or toolbar, then you should use QQmlApplicationEngine (with "ApplicationWindow":http://qt-project.org/doc/qt-5/qml-qtquick-controls-applicationwindow.html as your root). If you want to embed a QML GUI inside a widget GUI, you should use QQuickView (Qt 5.0 -- Qt 5.2) or QQuickWidget (Qt 5.3 and later). But if you don't need either of these, then it doesn't really matter which one you choose.
  • 0 Votes
    12 Posts
    4k Views
    jeremy_kJ
    Input handling can be pretty confusing, for developers and users.
  • Emit is not working when calling on a separate android thread

    2
    0 Votes
    2 Posts
    1k Views
    jeremy_kJ
    I wonder if the problem is due to the use of a static signal. Cross-thread signal delivery uses an event loop in the receiving thread. Intra-thread delivery is a direct call by default. The static use might confuse the detection of the correct connection type.
  • Error in runtime module "Customer" is not installed

    1
    0 Votes
    1 Posts
    534 Views
    No one has replied
  • 0 Votes
    6 Posts
    4k Views
    G
    Hi,shav Thanks for your reply! Here is a sample XML file "XML":http://i.imgur.com/HBdVeZI.png And here is the screenshot I want."view":http://i.imgur.com/QpXjDpJ.png Different components may have different Pins and Bindings in XML. So,I can have 2 LED with different pins. The list items in [Component] list box should be generated dynamically according to Modules.Component in XML. [Binding] column is list box with selection items in XML, and the binding items in list box differs base on the selection of [Component].
  • 0 Votes
    3 Posts
    1k Views
    J
    Hi, thanks a lot for the tip. I found the code I'm using here: http://answer.techwikihow.com/297416/ask-confirmation-before-closing-qquickview-qapplication.html I now tried another approach and installed an eventFilter which filters QEvent::Close. The code now looks like this: @class Window : public QtQuick2ApplicationViewer { QmltoCpp* qmltocpp; public: void setQmlClass(QmltoCpp* &qmlClass) { qmltocpp = qmlClass; } protected: bool eventFilter(QObject *obj, QEvent *ev) { if (ev->type() == QEvent::Close) { qmltocpp->exit(); return true; } else { return false; } } }; int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); Window viewer; viewer.installEventFilter(&viewer); viewer.setMainQmlFile(QStringLiteral("qml/MyApp/main.qml")); viewer.showExpanded(); return app.exec(); } @ The function qmltocpp->exit() writes the settings to database and then closes the app by calling @QGuiApplication::quit();@ It works as before on Windows 7, tomorrow I'll try it on my Windows 8 tablet. I hope it will work now.
  • QML row/column issues - Qt 5.3

    7
    0 Votes
    7 Posts
    2k Views
    J
    try: @brdImg: "qrc:/resources/MANO_Icon_Foto.png"@
  • Question on Animation

    3
    0 Votes
    3 Posts
    871 Views
    p3c0P
    Hi, AFAIK, the animation wont stop even if the visibility is turned to false.
  • Aggregating other QQuickPaintedItem derived Class.

    1
    0 Votes
    1 Posts
    461 Views
    No one has replied
  • How to use normal distribution in qt

    4
    0 Votes
    4 Posts
    4k Views
    JKSHJ
    [quote author="prabhatjha" date="1401269566"]i have already tried this example but in qt its not helpful.[/quote]Why?