Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k Topics 77.4k Posts
  • Tree View on QML

    4
    0 Votes
    4 Posts
    10k Views
    U
    :) Wow this post was unanswered for a long time which had me post a simplified version of the code I used in my project at http://www.codeproject.com/Articles/632795/QML-TreeModel-and-TreeView a few days back. Component recursion and apropriate javascript object for the model can build trees (etc.) of any complexity. The code is dynamic and can add / nest subnodes to any depth.
  • Who takes care of deleting QImage returned from QQuickImageProvider?

    4
    0 Votes
    4 Posts
    2k Views
    C
    It's a cache of QQuickPixmap rather than QPixmap. I should have been clearer. Probably best to read the code I linked at gitorious. To create a texture from a QPixmap, it is first converted to a QImage. The rest of the code is basically identical, and it's cached the same way (what is cached is QQuickPixmapData which consists of a texture factory for the image data). In short, two requests for the same QQuickPixmap (ie, see QQuickImage for an example) won't need to go through the provider->requestImage() or provider->requestPixmap() codepath; instead, the data will be returned directly from the cache. Performance should be mostly identical, I guess. Benchmark it to find out for yourself though, as I may be wrong about that. Certainly pixmap.toImage() must have some overhead. What is eventually rendered is a texture, not a pixmap or an image, of course. Cheers, Chris.
  • The model data in the model data

    2
    0 Votes
    2 Posts
    815 Views
    JKSHJ
    Hi, You probably want a tree model, not a list model. Let your top-level model have 1 column, and m rows for m people. Let each top-level item contain a child model with n rows for n phones. The child model should have 4 columns, one for each property of the phone (name, colour, model, image).
  • 0 Votes
    8 Posts
    3k Views
    SGaistS
    Read this "followup":http://woboq.com/blog/qthread-you-were-not-doing-so-wrong.html article. Most of the time you don't need to subclass but in some cases you have to
  • Best way to load an QML item from Qt plugin, written in C++

    1
    0 Votes
    1 Posts
    542 Views
    No one has replied
  • [SOLVED] Sorting in QtQuick 1.1 GridView

    3
    0 Votes
    3 Posts
    1k Views
    napajejenunedk0N
    Yes, I've already resolved the case by just calling the sort of the QSortFilterProxy model since it was not enough just to reimplement the lessThan() member function. Forgot to mark the topic as solved.
  • How to use "Qt Desktop Components" on Qt5

    11
    0 Votes
    11 Posts
    5k Views
    C
    So I finally figured it out. There's no QtQuick 2 template with C++ integration that supports QtQuick.Controls in QtCreator out of the box as of now (version 2.8). We will have to create an empty Qt project from scratch: File -> New File or Project -> Other Project -> Empty Qt Project let's name it 'mytestproject' Modify mytestproject.pro by adding this: @ TEMPLATE = app TARGET = mytestproject QT += qml quick widgets @ Add main.qml file to the project @ import QtQuick 2.1 import QtQuick.Controls 1.0 ApplicationWindow { id: rootWindow height: 500 width: 500 visible: true // <-- this is important because the window is hidden by default Button { text: "Quit app" anchors.centerIn: parent onClicked: { Qt.quit(); } } }@ Add main.cpp file to the project @ #include <QApplication> #include <QQmlApplicationEngine> int main(int argc, char** argv) { QApplication app(argc, argv); QQmlApplicationEngine engine("main.qml"); app.exec(); } @ Disable Shadow build QtCreator creates a shadow directory by default where it builds our application. i.e if our app is located at: /home/foo/mytestproject then it will create a debug and release directory at: /home/foo/mytestproject-Debug-Desktop /home/foo/mytestproject-Release-Desktop This means that inside 'main.cpp' the QQmlApplicationEngine won't be able to find our 'main.qml' file that we want to load. I don't know any other workaround, so let's just disable the shadow directory feature altogether and let's build our application inside it's folder. To do this click on the large Projects icon on the lefthand side of QtCreator and untick 'Shadow build'. Build Run and Enjoy Now the project should be building and we should be seeing a window with a buton.
  • Qt Quick controls styling ToolBar, MenuBar and StatusBar

    2
    0 Votes
    2 Posts
    2k Views
    J
    The simple answer is that you can only style those components that provide a style at the moments. The others will come in a later version. This includes MenuBar which is tricky as it depends on the platform if it can even be styled or not (think mac os/ubuntu). But ToolBar and StatusBar are actually quite easy to work around. Both of them can be replaced by any item. Ie to create a custom toolbar all you have to do is: @toolBar: Rectangle { color: "red" height: 40 width: parent.width }@ StatusBar is similar. The only drawback is that you have to provide your own margins and the tool bar will not automatically adjust to content height but that should be easily solved by adding anchors or a layout.
  • ScrollView and adding scrollbars to app window

    2
    0 Votes
    2 Posts
    998 Views
    J
    This is straight forward actually. ScrollView itself is not visible. All you have to do is to make the gradient rectangle the background, parent the scrollView inside it and create an invisible content item in the scroll Area: @ import QtQuick 2.0 import QtQuick.Controls 1.0 Rectangle { id: mainWindow gradient: Gradient { GradientStop { position: 0.0; color: "red"} GradientStop { position: 1.0; color: "blue" } } Text { anchors.centerIn: parent text: "Hello World" } ScrollView { anchors.fill: parent Item { width: 360 height: 360 } } } @
  • QtQUICK 2.0 vs C++ Widget

    2
    0 Votes
    2 Posts
    1k Views
    J
    Just make a subclass of QQuickPaintedItem and draw your graph in the paint method, just as you would in a normal widget. Then expose it to qml by registring the type. There should be several examples of this. Alternatively you can draw the graph using Canvas + javascript itself.
  • Qt Quick controls styling

    4
    0 Votes
    4 Posts
    2k Views
    J
    No as you can imagine a MenuBar takes a lot more to style than just a rectangle and it cannot yet be styled through the public API.
  • Javascript library internationalization

    2
    0 Votes
    2 Posts
    915 Views
    P
    problem found, bug reported "https://bugreports.qt-project.org/browse/QTBUG-32850":https://bugreports.qt-project.org/browse/QTBUG-32850
  • Question around internationalization in QML

    21
    0 Votes
    21 Posts
    17k Views
    V
    @digital_aspirin Hi,, How to achieve your method can you explain bit detail
  • Are components loaded by Loader cached somehow?

    3
    0 Votes
    3 Posts
    852 Views
    P
    Thanks. The thread you mention shows more of a hack, than a good solution. I will dig into the source a bit more
  • [solved] QDeclarativeItem wrong MouseArea

    1
    0 Votes
    1 Posts
    846 Views
    No one has replied
  • Translations in QML files

    2
    0 Votes
    2 Posts
    4k Views
    V
    Hi,, I stuck in same problem did you solve it,?
  • OnEntered during mouse drag

    6
    0 Votes
    6 Posts
    2k Views
    H
    Weird! Hoped the workaround might have worked. The mouse event seems to be suppressed (like when using propagateComposedEvents: or preventStealing:). Perhaps this is the issue? I'm afraid we need some expert on this... it's probably some simple setting. A bug like this would have been caught - right?
  • The QML Script Console

    4
    0 Votes
    4 Posts
    3k Views
    P
    Thanks for the swift response!
  • FileDialog crashes sometimes in Debug, seems to behave ok in Release

    4
    0 Votes
    4 Posts
    3k Views
    K
    There is a "bug report":https://bugreports.qt-project.org/browse/QTBUG-32821 referenced. The bug report is on windows with Qt 5.1.
  • Lock children inside parent

    4
    0 Votes
    4 Posts
    1k Views
    H
    That was it!! Thanks a lot... I sure did hate that dummy rectangle hack I made!