Skip to content

Instantly share code, notes, and snippets.

@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/*
#ifndef QQMLOBJECTLISTMODEL_H
#define QQMLOBJECTLISTMODEL_H
#include "qqmlmodels.h"
#include <QByteArray>
#include <QChar>
#include <QDebug>
#include <QHash>
#include <QList>
#include <QMetaMethod>
import QtQuick 2.2
pragma Singleton
QtObject {
signal openItem(id)
signal removeItem(id)
}
@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
  }
}
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 / 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
@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;
}
var sections = document.querySelectorAll(".sg-section");
var ul = document.createElement('ul');
sections[0].parentNode.insertBefore(ul, sections[0]);
for (var i=0; i < sections.length; ++i) { var elem = sections[i].children[0]; var li = document.createElement('li'); li.innerHTML='<a href="#'+elem.id+'">'+elem.textContent+'</a>'; ul.appendChild(li); }
import QtQuick 2.0
Item {
id: root
height: 0
default property alias data: contentItem.data
property ListView _listView: parent.parent
property Item _adjacentItem: { _listView.contentY; return _listView.itemAt(0, y); }
property bool _adjacentItemIsLastOfSection: _adjacentItem ? _adjacentItem.ListView.section !== _adjacentItem.ListView.nextSection && _adjacentItem !== _listView.contentItem.children[0] : false
import QtQuick 2.0
/*!
\qmltype AreaTester
\brief A component that highlights the aera of a given component.
The AreaTester component is a simple component to troubleshoot what area occupies an other component.
You can use this component like this to highlights its parent's area.
\qml
Item {
id: itemToHighlight