Skip to content

Instantly share code, notes, and snippets.

@mitchcurtis
mitchcurtis / main.cpp
Created May 30, 2024 07:03
Execute shell script using QProcess
#include <QCoreApplication>
#include <QProcess>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
QProcess process;
QObject::connect(&process, &QProcess::errorOccurred, [&process](){
@mitchcurtis
mitchcurtis / qemu-armv7-ci-build-setup.sh
Last active March 22, 2024 03:33
Qt QEMU armv7 Ubuntu CI build setup script
if [ ! -d "/home/qt/work/qt-dev" ]; then
cd /home/qt/work
git clone https://code.qt.io/qt/qt5.git qt-dev
cd qt-dev
perl init-repository --module-subset=qtbase
fi
mkdir /home/qt/work/qt-dev-release/
mkdir /home/qt/work/qt-dev-release/qtbase
mkdir /home/qt/work/qt-dev-release/qtbase/build
@mitchcurtis
mitchcurtis / main.cpp
Last active February 26, 2024 08:13
Widgets menu example - QMenuBar, QMenu, QComboBox
#include <QtWidgets>
int main(int argc, char *argv[])
{
// QApplication::setAttribute(Qt::AA_DontUseNativeMenuBar);
// QApplication::setAttribute(Qt::AA_DontUseNativeMenuWindows);
QApplication app(argc, argv);
QMainWindow mainWindow;
@mitchcurtis
mitchcurtis / Main.qml
Last active August 8, 2023 08:32
Qt Quick palette legend
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
ApplicationWindow {
id: root
width: 640
height: 480
visible: true
@mitchcurtis
mitchcurtis / main.qml
Created October 4, 2022 09:05
FrameNumberAnimation
// FrameAnimation that operates on a property, like NumberAnimation,
// except the duration and easing can be change while it's animating.
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
ApplicationWindow {
id: window
width: 640
@mitchcurtis
mitchcurtis / clean-rebuild-qt-cmake-linux.sh
Created October 30, 2021 12:16
Build scripts for Qt on Linux
#! /bin/bash
# ~/Dropbox/dev/scripts/cmake/clean-rebuild-qt-cmake-linux.sh
set -e
set -o pipefail
topLevelSourceDir=$1
topLevelBuildDir=$2
configPath=$3
@mitchcurtis
mitchcurtis / qt-git-sync-to.sh
Created October 30, 2021 12:08
Script to sync Qt modules
#!/bin/bash
usageExample="Usage: cd ~/dev/qt-dev/qtdeclarative && git fetch && git reset --hard origin/dev && cd .. && qt-git-sync-to.sh qtdeclarative HEAD"
if [ -z "$1" ]; then
echo "module argument not supplied"
echo $usageExample
exit 1
fi
@mitchcurtis
mitchcurtis / main.cpp
Created October 19, 2021 12:14
A hacky way of setting a custom delegate for QListView
#include <QtWidgets>
#include <QDebug>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QMainWindow mainWindow;
QWidget *centralWidget = new QWidget;
@mitchcurtis
mitchcurtis / main.qml
Last active October 9, 2021 10:41
Scene that can be dragged with middle mouse button
import QtQuick
import QtQuick.Window
import Qt.labs.animation
Window {
width: 640
height: 480
visible: true
title: qsTr("Test")
@mitchcurtis
mitchcurtis / main.qml
Last active July 6, 2021 14:09
ListView with array model of copyable colours
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
ApplicationWindow {
id: window
width: 600
height: 600
visible: true
title: "colours"