Skip to content

Instantly share code, notes, and snippets.

@oKcerG
oKcerG / descendant.qml
Created September 28, 2016 12:30
Access a descendant of an Item in QML
function descendant() {
var object = arguments[0];
for (var i = 1; i < arguments.length; ++i)
object = object.children[arguments[i]];
return object;
}
@oKcerG
oKcerG / DraggableItem.qml
Created June 14, 2016 17:24
PoC detachable QML Item
import QtQuick 2.0
import QtQuick.Window 2.2
Item {
id: root
readonly property alias dragging: mouseArea.pressed
property bool lol: true
property Window targetWindow: lol ? win2 : window1
implicitWidth: draggable.childrenRect.width
implicitHeight: draggable.childrenRect.height
import QtQuick 2.4
Item {
id: root
default property alias data: contentItem.data
readonly property bool showing: listView.currentIndex === 0
property double peekWidth: 48
property double touchWidth: 32
property double paneWidth: Math.min(root.width - 128, 640)
Text { text: paneWidth }
system(/usr/local/bin/qpm install) {
include(vendor/vendor.pri)
} else {
QPM_URL = https://qpm.io
equals(QMAKE_HOST.os, "Darwin") : system(open $$QPM_URL)
equals(QMAKE_HOST.os, "Windows") : system(start $$QPM_URL)
error(qpm is not installed in PATH)
}
@oKcerG
oKcerG / YourWindow.qml
Last active January 25, 2016 11:20 — forked from benlau/YourWindow.qml
Connections {
target: AppActions
onOpenItem: {
/// Create new window and open item
}
onAskToRemoveItem: {
/// Open a dialog
  }
}
import QtQuick 2.2
pragma Singleton
QtObject {
signal openItem(id)
signal removeItem(id)
}
#ifndef QQMLOBJECTLISTMODEL_H
#define QQMLOBJECTLISTMODEL_H
#include "qqmlmodels.h"
#include <QByteArray>
#include <QChar>
#include <QDebug>
#include <QHash>
#include <QList>
#include <QMetaMethod>
@oKcerG
oKcerG / qtdoc-github-viewsource.user.js
Last active August 29, 2015 14:21
GitHub link in Qt.io Documentation userscript
// ==UserScript==
// @name GitHub link in Qt.io Documentation
// @namespace http://grecko.fr/
// @version 0.4.1
// @description Add a link to view the source of a class/component on Qt.io documentation pages.
// @author GrecKo
// @match http://doc.qt.io/*
// @match https://doc.qt.io/*
// @match http://doc-snapshots.qt.io/*
// @match https://doc-snapshots.qt.io/*