import images directory ?
-
hi everyone ,
i cant load image from images directory. How can use currentdir in qml
main.cpp code is
<code>
qmlRegisterType<Object>("org.yeni.example", 1, 0, "Object");
qmlRegisterType<Getsqlmodel>("org.qtproject.examples.calendar1", 1, 0, "Getsqlmodel");QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
</code>
-
Hi @mehmetak
Where is this images directory ? If it is in same directory wheremain.qml
is present then you can access images from it using the relative path. Something like://main.qml ... source: "images/someimage.png"
-
i solved problem with c++ integration .
Object.cpp
QString Object::deneme(QString dd) {
QDir ss ; return ss.absolutePath()+'/'+dd;
}
main.cpp
qmlRegisterType<Object>("org.yeni.example", 1, 0, "Object");
qmlRegisterType<Getsqlmodel>("org.qtproject.examples.calendar1", 1, 0, "Getsqlmodel");main.qml
import org.qtproject.examples.calendar1 1.0
import org.yeni.example 1.0...................
..................
Object {
id:getir
}Getsqlmodel {
id:sqlQ
}Image {
id:rocket
// source:'http://play.brokt.com/~fritzy/rocket.png'
source:'file:' + getir.deneme('debug/rocket.png')
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
} -
@mehmetak Ok. That's great. But I think it should be accessible by relative path too.
-
@p3c0 thx p3c0 . i liked c++ integration.