Добавил:
Только когда поступишь в технический вуз поймешь на сколько ты гуманитарий Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Дополнительные материалы.pdf
Скачиваний:
3
Добавлен:
07.06.2025
Размер:
12.29 Mб
Скачать

РАЗРАБОТКА НА QT ДЛЯ МОБИЛЬНЫХ УСТРОЙСТВ

ПРИМЕР QABSTRACTLISTMODEL

#include <QAbstractListModel>

class DemoModel : public QAbstractListModel

{

Q_OBJECT

public:

enum DemoRoles {

NameRole = Qt::UserRole + 1,

};

explicit DemoModel(QObject *parent = 0);

virtual int rowCount(const QModelIndex&) const { return backing.size(); } virtual QVariant data(const QModelIndex &index, int role) const; QHash<int, QByteArray> roleNames() const;

Q_INVOKABLE void activate(const int i);

private:

QVector<QString> backing;

};

РАЗРАБОТКА НА QT ДЛЯ МОБИЛЬНЫХ УСТРОЙСТВ

ПРИМЕР QABSTRACTLISTMODEL

DemoModel::DemoModel(QObject *parent) : QabstractListModel(parent) { backing << "sea cow" << "platypus" << "axolotl"

<< "quokka" << "pitahui" << "jerboa";

}

QHash<int, QByteArray> DemoModel::roleNames() const { QHash<int, QByteArray> roles;

roles[NameRole] = "name"; return roles;

}

QVariant DemoModel::data(const QModelIndex &index, int role) const { if(!index.isValid())

return Qvariant(); if(role == NameRole)

return Qvariant(backing[index.row()]); return Qvariant();

}

РАЗРАБОТКА НА QT ДЛЯ МОБИЛЬНЫХ УСТРОЙСТВ

ПРИМЕР QABSTRACTLISTMODEL

void DemoModel::activate(const int i) { if (i < 0 || i >= backing.size())

return;

QString value = backing[i];

//Remove the value from the old location. beginRemoveRows(QModelIndex(), i, i); backing.erase(backing.begin() + i); endRemoveRows();

//Add it to the top.

beginInsertRows(QModelIndex(), 0, 0); backing.insert(0, value); endInsertRows();

}

РАЗРАБОТКА НА QT ДЛЯ МОБИЛЬНЫХ УСТРОЙСТВ

РЕСУРСЫ ДЛЯ РАЗРАБОТЧИКОВ В ИНТЕРНЕТЕ

Qt Quick — about product www1.qt.io/qt-quick/

Qt Quick doc.qt.io/qt-5/qtquick-index.html

QML Applications doc.qt.io/qt-5/qmlapplications.html

aurora-os.ru/vk

aurora-os.ru/telegram

All QML Types doc.qt.io/qt-5/qmltypes.html

QML Coding Conventions doc.qt.io/qt-5.6/qml-codingconventions.html

Qt Declarative Online Coding App

www.qt.io/product/development-tools/qml-online-d eclarative-coding-app

aurora-os.ru/stepik

aurora-os.ru/youtube

aurora-os.ru/habr