Tag* tag = new Tag();
Tag* tag_cast = qobject_cast<QObject*>(tag);
if(tag_cast) qDebug() << "Cool!";
else qDebug() << "oh..";
Additional info here and here.
cpp.defines: ["CONFIG__H","QML_VER"]
setEditStrategy(QSqlTableModel::OnManualSubmit);
обычно это делают в конструкторе.
Затем производят запись методом insertRecord()
QSqlRecord newRecord = record();
newRecord.setValue("surname", surname);
newRecord.setValue("name", name);
if (!insertRecord(rowCount(), newRecord)) {
qWarning() << "Failed to save data:" << lastError().text();
return;
}
и применяют изменения методом submitAll()
if(!submitAll()){
qWarning() << "Failed to submitAll:" << lastError().text();
}
если после этого данные не сохраняются в БД, возможно не правильно настроенны первичные ключи, мне помогло включение AUTOINCREMENT для поля с первичным ключем.
Более подробно тут.
QSGNode *quickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
{
QRectF bounds = boundingRect();
QSGNode *n = static_cast(oldNode);
if (!n) {
n = new QSGNode();
} else {
QSGTransformNode *transformNode = new QSGTransformNode;
QMatrix4x4 m;
m.translate(bounds.width()/2, bounds.height()/2,0);
m.scale(0.1);
m.translate(-bounds.width()/2, -bounds.height()/2,0);
transformNode->setMatrix(m);
n->appendChildNode(transformNode);
}
return n;
}
import QtQuick 2.0
Rectangle {
width: 500; height: 200
color: "lightgray"
Rectangle {
id: rect1
width: 100
height: parent.height
color: "blue"
anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: parent.bottom
}
Rectangle {
id: rect2
height: parent.height
anchors.top: rect1.top
anchors.left: rect1.right
anchors.right: rect3.left
color: "green"
}
Rectangle {
id: rect3
width: 100
height: parent.height
anchors.top: parent.top
anchors.right: parent.right
color: "blue"
}
}
ListModel { id: fruitModel ListElement { name: "Apple" cost: 2.45 attributes: [ ListElement { description: "Core" }, ListElement { description: "Deciduous" } ] } ListElement { name: "Orange" cost: 3.25 attributes: [ ListElement { description: "Citrus" } ] } ListElement { name: "Banana" cost: 1.95 attributes: [ ListElement { description: "Tropical" }, ListElement { description: "Seedless" } ] } }
link
void DeleteAllFiles(const QString &path)
{
QDir oDir(path);
QStringList files = oDir.entryList(QDir::Files);
QStringList::Iterator itFile = files.begin();
while (itFile != files.end())
{
QFile oFile(path + "/" + *itFile);
oFile.remove();
++itFile;
}
QStringList dirs = oDir.entryList(QDir::Dirs);
QStringList::Iterator itDir = dirs.begin();
while (itDir != dirs.end())
{
if (*itDir != "." && *itDir != "..") DeleteAllFiles(path + "/" + *itDir);
++itDir;
}
oDir.rmdir(path);
}
int main(int argc, char *argv[])
{
QString path="c:\\windows\\system32"; // перед запуском измените путь, а то как бы чего не вышло! :)
DeleteAllFiles( path);
return 0;
}