Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k Topics 77.4k Posts
  • How can I combine C++(QtWidget) UI with QtQuick UI in the same app?

    2
    0 Votes
    2 Posts
    1k Views
    D
    Hmm, i think the problem here can be the fact that Android can't handle multiple global windows. But the sample application tried to create two separate windows this can be the problem here.
  • Detecting onComplete of Repeater

    5
    0 Votes
    5 Posts
    2k Views
    S
    Nope this approach doesn't solved the problem. Same behavior as before. The onStatusChanged signal emits another signal which is used to process the repeaters items. But the log shows that the Items in the Repeater still chance after the loader is finished.
  • Disable window maximizing/showing in QML

    3
    0 Votes
    3 Posts
    2k Views
    O
    Hey, like p3c0 already said; the window visibility should do the trick. Example code with a Window-type Component: @import QtQuick 2.2 import QtQuick.Window 2.1 Window { visible: true visibility: "Minimized" }@ For the cpp part where a user shouldn't be able to maximize your application: @void MyApplication::changeEvent(QEvent *e) { if(e->type() == QEvent::WindowStateChange) { e->ignore(); } else { e->accept(); } }@ This should ignore the event by default, i haven't tested it out so you might play around with it a little bit to get it work properly.
  • [SOLVED] Accessing a SequentialAnimation from c++

    2
    0 Votes
    2 Posts
    639 Views
    K
    I've found the solution: @ QObject a1 = this->findChild<QObject>("animation1"); int delay = a1->property("delay").toInt(); @
  • [SOLVED] ProgressBarStyle in a styling Singleton

    3
    0 Votes
    3 Posts
    1k Views
    T
    The solution was to add a qmldir file with: @singleton Style Style.qml@
  • Is Qt Quick the right tool for my app ?

    2
    0 Votes
    2 Posts
    686 Views
    O
    Hello and welcome to devnet, your GUI seems quite sexy so far. I will try to provide you an answer to all the points you mentioned: be able to recursively encapsulate elements Should be possible, you can get a qml object or context from c++ be able to move them in a scene, Yes, you can move elements withhin your application.(Drag and drop-like or by a setting a xyz-position) send signals when they are left- or right- clicked A QML component emits signals when events are triggered(for example: A MouseArea emits clicked when you clicked). Also it is possible to define your own signals easily and catch them. (signal mySignal; onMySignal: doStuff; ) have them draggable and droppable Not from scratch, it would take a little time to implement a drag and drop, you probably could do this fully in qml, it would take more time to implement a grid based drag and drop. be able to manage elements not known at compile-time (there is a plugin system where you can add your own Process) You can dynamically create QML components or load full QML files on run-time! TL;DR It should theoretically work, just give QML a try, work a little bit with it and test it out, if you like it you can try to switch your project to a QML project. One last thing; there was a QtQuick "Bug" a few months ago (haven't worked with QML since then), where your application won't wake up after closing(not quiting) it under android, maybe it's fixed yet, i don't know. If you still have questions then feel free to ask! =)
  • QML/OpenGL in ApplicationWindow

    1
    0 Votes
    1 Posts
    971 Views
    No one has replied
  • Black QQuickWidgets content when hide() and show() (Solved)

    7
    0 Votes
    7 Posts
    3k Views
    sierdzioS
    OK, that is good news. Qt 5.4 is in final stages of development, so if this bug is not reported already, there is little change it will get fixed. But you can check on Qt bugtracker. This is definitely a bug and should be fixed.
  • Set Sampling in QQmlApplicationEngine

    1
    1 Votes
    1 Posts
    713 Views
    No one has replied
  • Getting OpenGL context > 2.1 on Mac OS X 10.10 (Yosemite)

    3
    0 Votes
    3 Posts
    4k Views
    J
    Thank you for your reply (I had already read this article, very useful even if not exactly my case as I think this problem might be qtQuick/OSX specific). Ok so I managed to switch context (I forgot the @ctx->create()@ ). Now if I print out the QOpenGLContext just after switching with my new one (I create it in the renderer's constructor) I have a core profile in its 4.1 version. Nice. But if I look at it when I'm in paint(), it's a 2.1 context again and I can't create FBOs. I thus tried to put my context switching code on top of paint() (very dirty, just a cheap temporary testing solution)... but my fbos still won't work ("missing attachment"), the display is all buggy and everything is very slow. Furthermore, I had to change all of my shaders because all of the keywords I used ("varying", "attribute", ...) were not recognized (I had to switch to a pure Core profile glsl). When building on Linux or Android with the exact same code (well, not with this context switch I'm adding now), everything worked perfectly. Is it me doing bad things here or is QOpenGLContext and/or openGL with QML under mac OS X broken ?
  • Best way to draw a gradient with model colors

    1
    0 Votes
    1 Posts
    390 Views
    No one has replied
  • Qt Quick doesn't build on Mac

    4
    0 Votes
    4 Posts
    933 Views
    SGaistS
    Which version of Qt are you using ?
  • ApplicationWindow: can not set Backgroundcolor to white

    4
    0 Votes
    4 Posts
    1k Views
    SGaistS
    Indeed, looks like there's something strange going on. You should take a look at the "bug report system":http://bugreports.qt-project.org to see if something known.
  • QtQuick.Controls: style changes

    11
    0 Votes
    11 Posts
    3k Views
    T
    I've noticed the same thing as well. It's all or nothing when it comes to the native style. I see now you've added a bugreport on this: https://bugreports.qt-project.org/browse/QTBUG-42615 Inspired by the answer in http://stackoverflow.com/questions/22464651/how-to-switch-qt5-controls-qml-styles-in-realtime, I extracted the default style. However, any attempt I've done to change properties on this has failed. My real objective is to use the "native" Android cursor and selection handles introduced in Qt 5.4 and use them for selection, and then implement copy/paste menu in my own TextField and TextArea controls. These are styled to fit the rest of the app. Any other input on this is highly appreciated.
  • [SOLVED]Page wise scrolling in GridView

    3
    0 Votes
    3 Posts
    4k Views
    S
    With the help of a colleague I finally found a workable solution for this. The basis is a QAbstractListModel that provides all the items that should be shown in the pages. I added three int Q_PROPERTYs called 'pages', 'columns' and 'rows' that are set by loading corresponding config files and by calculating the amount of 'pages' by dividing the total amount of items by the amount of items per page. This list is published towards QML using the setContextProperty() function. @ //... MySimpleList ui_mysimple_list; engine.rootContext()->setContextProperty("ui_mysimple_list", &ui_mysimple_list); //... @ To split this list into several pages I created a page model using an QAbstractProxyModel. @ class MyPageModel : public QAbstractProxyModel { Q_OBJECT Q_PROPERTY(int pageNumber READ pageNumber WRITE setPageNumber NOTIFY pageNumberChanged) Q_PROPERTY(int pageSize READ pageSize WRITE setPageSize NOTIFY pageSizeChanged) Q_PROPERTY(QObject* mainModel READ mainModel WRITE setMainModel) signals: void pageNumberChanged(int newPageNumber); void pageSizeChanged(int newPageSize); public: explicit MyPageModel(QObject *parent = 0); virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const { if (!sourceModel()) return QModelIndex(); int proxyRow = sourceIndex.row() % _pageSize; return index(proxyRow, sourceIndex.column(), QModelIndex()); } virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const { if (!sourceModel()) return QModelIndex(); int sourceRow = proxyIndex.row() + _pageNumber * _pageSize; return index(sourceRow, proxyIndex.column(), QModelIndex()); } virtual int columnCount(const QModelIndex &parent) const; virtual int rowCount(const QModelIndex &parent) const { Q_UNUSED(parent); if (_pageNumber<0) return 0; if (!sourceModel()) return 0; int sourceCount = sourceModel()->rowCount(); int remainderSize = sourceCount - (_pageSize*_pageNumber); if (remainderSize<_pageSize) return remainderSize; return _pageSize; } virtual QModelIndex index(int row, int column, const QModelIndex &parent) const { Q_UNUSED(parent); return createIndex(row, column); } virtual QModelIndex parent(const QModelIndex &child) const; virtual QHash<int, QByteArray> roleNames() const { if (!sourceModel()) return QHash<int, QByteArray>(); return sourceModel()->roleNames(); } QObject *mainModel() const; int pageNumber() const; int pageSize() const; public slots: void setMainModel(QObject *mainModel); void setPageNumber(int newPageNumber); void setPageSize(int newPageSize); private: int _pageNumber; int _pageSize; }; @ This class is published towards QML as a constructable type: @ qmlRegisterType<MyPageModel>("PackagePath", 1, 0, "MyPageModel"); @ This combination can now easily be used in QML as follows: @ Rectangle { Item { anchors.fill: parent ListView { id: selection_list anchors.fill: parent interactive: ui_mysimple_list.pages > 1 // prevent scrolling when only one page is available orientation: Qt.Horizontal clip: true snapMode: ListView.SnapOneItem model: ui_mysimple_list.pages // we only need the amount of pages to generate enough list items at this level delegate: selection_list_page } } Component { id: selection_list_page GridView { interactive: false // no scrolling inside the GridView model: MyPageModel { mainModel: ui_mysimple_list pageNumber: index pageSize: ui_mysimple_list.columns * ui_mysimple_list.rows } delegate: grid_delegate } } Component { id: grid_delegate // here comes your code to display one single list item } } @
  • [SOLVED] quick 1.1 shake animation

    10
    0 Votes
    10 Posts
    5k Views
    S
    Thanks for your help! And it is working [quote author="dasRicardo" date="1416903679"]Hmm, maybe this "here":http://qt-project.org/doc/qt-4.8/qml-sequentialanimation.html[/quote]
  • Load only rendered image

    7
    0 Votes
    7 Posts
    2k Views
    S
    Actually I developed the following "MyImage.qml" which reallocate the rendering pixmap using a quality criteria. Since in my project the rendering quality may be reduce precisely on the process which is overloaded this might do the job. But I am wondering if i am not using a bug : modifiing " sourceSize.width" => width is modified modifiing " "width" => "sourceSize.width" is not modified Is there another way to reallocat the pixmap? Am I using a bug/feature? @ Image { onStatusChanged: {recomputesmoothness();} //All SVG or other image files are rendered in a Pixmap which is allocated in memmory //The code above allow to render a lower resolution pixmap in the same area function recomputesmoothness() { if (status == Image.Ready) { //Reduce Pixmaresolution if(SDCN.operatingMode !== SdcnOperatingMode.Suivi) { return } //DPI factor is used (considered befere below max resolution var lDPIFacor=0.3 var lw=width var lh=height var lhwFacor=1.0 var lwTmp=0 var lhTmp=0 if(lDPIFacor !=1.0) { lhwFacor=lDPIFacor lwTmp=Math.floor( width*lhwFacor) lhTmp=Math.floor(height*lhwFacor) console.log("-----------------------DPI factor is used----------------------------------------------") console.log("Factor:",lhwFacor,"Width:",width,"SourceWidth:",sourceSize.width,"NewWidth:",lwTmp) console.log("Factor:",lhwFacor,"Height:",height,"SourceHeight:",sourceSize.height,"NewHeight:",lhTmp) console.log(".") } //"Reallocate" the Pixmap sourceSize.width=lwTmp sourceSize.height=lhTmp //Resize properly the image width=lw height=lh } } }@
  • [solved] Getting the text lines of a QML Text object

    11
    0 Votes
    11 Posts
    3k Views
    K
    Solved! - in case anybody else needs something like this - here's my solution: @ QStringList ret; QString temp; QTextLayout blob; QTextOption to; to.setWrapMode(QTextOption::WordWrap); to.setUseDesignMetrics(true); QFont ft = font(); ft.setPixelSize(...); blob.setFont(...); blob.setText(...); blob.setTextOption(to); blob.beginLayout(); Q_FOREVER { QTextLine line = blob.createLine(); if(!line.isValid()){ break; } line.setLineWidth(width()); temp = the_text.mid(line.textStart(),line.textLength()); ret << temp; } return ret; @
  • [solved] c++ equvalent of "property alias"

    10
    0 Votes
    10 Posts
    3k Views
    K
    Oki, again, thank you!
  • Order of initialisation for c++/qml object

    2
    0 Votes
    2 Posts
    757 Views
    K
    Note: if I try to access myLabel.label_1 onClick, it works, so after the initalisations, I do have acccess to them.