{"id":426,"date":"2011-12-19T08:00:43","date_gmt":"2011-12-19T07:00:43","guid":{"rendered":"http:\/\/www.thelins.se\/johan\/blog\/?p=426"},"modified":"2011-12-18T16:45:19","modified_gmt":"2011-12-18T15:45:19","slug":"qtquick-and-models","status":"publish","type":"post","link":"https:\/\/www.thelins.se\/johan\/blog\/2011\/12\/qtquick-and-models\/","title":{"rendered":"QtQuick and Models"},"content":{"rendered":"<p>Well, the title says it all, lets get started :-)<\/p>\n<h3>Proxy Models<\/h3>\n<p>Something that I would love to see in QML is the QSortFilterProxyModel. I guess it needs a wrapper of some sort, but being able to sort and filter &#8211; either based on a role and a regular expression, or based on a JavaScript function would make QML even more powerful.<\/p>\n<p>Why is this an important feature? To me, the goal of using QML is to put all user-interface specific code in the QML-half of the equation. Adding capabilities to do sorting, and some filtering, to QML reduces the size of the C++ run-time and further decouples the data from how the data is shown.<\/p>\n<h3>Lazy Models<\/h3>\n<p>A long time ago (pre 4.7.4) I ran into the issue that when resetting a lazy model (i.e. a model implementing <a href=\"http:\/\/developer.qt.nokia.com\/doc\/qt-4.8\/itemviews-fetchmore.html\">canFetchMore \/ fetchMore<\/a>) does not trigger QML to poke at canFetchMore. Very annoying, but sorted in later versions of Qt.<\/p>\n<h3>Namespace Clashes<\/h3>\n<p>In my experience, QML needs the &#8220;::&#8221; operator. Binding text to the text from a model using &#8220;<tt>text: text<\/tt>&#8221; does not work. Being able to say &#8220;<tt>text: ::text<\/tt>&#8220;, or &#8220;<tt>text: data.text<\/tt>&#8221; would be nice. Even though the last approach prevents the usage of components with properties named <tt>data<\/tt>.<\/p>\n<p>I guess there already might be a way to achieve this, but I&#8217;ve not found it. If so, please tell me!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Well, the title says it all, lets get started :-) Proxy Models Something that I would love to see in QML is the QSortFilterProxyModel. I guess it needs a wrapper of some sort, but being able to sort and filter &#8211; either based on a role and a regular expression, or based on a JavaScript &hellip; <a href=\"https:\/\/www.thelins.se\/johan\/blog\/2011\/12\/qtquick-and-models\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">QtQuick and Models<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-426","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/posts\/426","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/comments?post=426"}],"version-history":[{"count":2,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/posts\/426\/revisions"}],"predecessor-version":[{"id":431,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/posts\/426\/revisions\/431"}],"wp:attachment":[{"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/media?parent=426"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/categories?post=426"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/tags?post=426"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}