Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.1k Topics 77.6k Posts
  • How to make QQuickView scrollable?

    3
    0 Votes
    3 Posts
    2k Views
    F
    Ok, thank you for answer. Meanwhile I decide to use QGraphicsScene and set QQuickView aside, in spite of advantages like QML 2.0. I set this thread not as solved, in case somebody else still searching another answer to this question or somebody else knows another answer, too.
  • [Solved]Get ListModel count outside of delegate...

    3
    0 Votes
    3 Posts
    1k Views
    Q
    Thanks for your quick response! I am impressed by the speed I can get help from this forum.
  • [SOLVED] import components from qrc

    4
    0 Votes
    4 Posts
    2k Views
    G
    Thanks for your replies. Solved.
  • Quick 2.0 import delegate

    2
    0 Votes
    2 Posts
    835 Views
    V
    solution 1. put your qml files into Qt resource system. solution 2 copy your qml files to the folder in which your program is executed.
  • Providing absolute/relative file path

    4
    0 Votes
    4 Posts
    2k Views
    p3c0P
    bq. I know this,but I don’t want to put images inside qrc as binary size will increase. Then you need to provide absolute paths or relative paths ( if the file you know is several directories up using "../../../clover.png" for e.g ) bq. Also,I have another query. Putting relative path provides me “file:///” whereas I have to manually append “file:///” while providing absolute image path. AFAIK, Yes
  • how to use a class written in javascript to qml ?

    6
    0 Votes
    6 Posts
    2k Views
    JKSHJ
    [quote author="chrisadams" date="1387157603"]The 'var' property type is only available in QtQuick 2.0, not in QtQuick 1.0. (Well, technically, in QtQml 2.0, but yeah.)[/quote]Ah, good catch. september, are you able to upgrade to Qt Quick 2? Qt Quick 1 is obsolete now.
  • 0 Votes
    11 Posts
    8k Views
    B
    I haven't started using Qt 5, so I'm not sure if it does this. This plugin is good for this and it's also good for implementing a screen saving feature. Here is the plugin code: @ #include <qdeclarative.h> #include <QObject> #include <QEvent> #include <QKeyEvent> #include <QMouseEvent> #include <QBool> #include <QApplication> #include <QDebug> class QMLKeyEvent : public QObject { Q_OBJECT Q_PROPERTY(int key READ key) Q_PROPERTY(QString text READ text) Q_PROPERTY(int modifiers READ modifiers) Q_PROPERTY(bool isAutoRepeat READ isAutoRepeat) Q_PROPERTY(int count READ count) Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted) Q_PROPERTY(int nativeScanCode READ nativeScanCode) Q_PROPERTY(int type READ type) public: QMLKeyEvent(const QKeyEvent &ke, const int n = 0) : _event(ke), _nativeScanCode(n) { _event.setAccepted((false)); } int key() const { return _event.key(); } QString text() const { return _event.text(); } int modifiers() const { return _event.modifiers(); } bool isAutoRepeat() const { return _event.isAutoRepeat(); } int count() const { return _event.count(); } bool isAccepted() const { return _event.isAccepted(); } void setAccepted(bool accepted) { _event.setAccepted(accepted); } int nativeScanCode() const { return _nativeScanCode; } int type() const { return _event.type(); } private: QKeyEvent _event; int _nativeScanCode; }; class QMLMouseEvent : public QObject { Q_OBJECT Q_PROPERTY(int x READ x) Q_PROPERTY(int y READ y) Q_PROPERTY(int globalX READ globalX) Q_PROPERTY(int globalY READ globalY) Q_PROPERTY(int button READ button) Q_PROPERTY(int buttons READ buttons) Q_PROPERTY(int modifiers READ modifiers) Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted) public: QMLMouseEvent(const QMouseEvent &me) : _event(me) { _event.setAccepted(false); } int x() const { return _event.x(); } int y() const { return _event.y(); } int globalX() const { return _event.globalX(); } int globalY() const { return _event.globalY(); } int button() const { return _event.button(); } int buttons() const { return _event.buttons(); } int modifiers() const { return _event.modifiers(); } bool isAccepted() { return _event.isAccepted(); } void setAccepted(bool accepted) { _event.setAccepted(accepted); } private: QMouseEvent _event; }; QML_DECLARE_TYPE(QMLKeyEvent) QML_DECLARE_TYPE(QMLMouseEvent) class UserEventFilter : public QObject { Q_OBJECT Q_PROPERTY(bool enabled READ getEnabled WRITE setEnabled NOTIFY enabledChanged) public: UserEventFilter(QObject * parent = 0); virtual ~UserEventFilter(); public: // for properties bool getEnabled() const; void setEnabled(const bool enabled); signals: // for properties void enabledChanged(bool newEnabled); signals: void userEventOccurred(); void keyPressed(QMLKeyEvent *event); void keyReleased(QMLKeyEvent *event); void mousePressed(QMLMouseEvent *event); void mouseReleased(QMLMouseEvent *event); void mouseMoved(QMLMouseEvent *event); private: bool processKeyPress(QEvent *event); bool processKeyRelease(QEvent *event); bool processMouseButtonPress(QEvent *event); bool processMouseButtonRelease(QEvent *event); bool processMouseMove(QEvent *event); private: // for properties bool _enabled; protected: bool eventFilter(QObject * obj, QEvent * event); }; UserEventFilter::UserEventFilter(QObject * parent) : QObject(parent) { _enabled = true; qApp->installEventFilter(this); } UserEventFilter::~UserEventFilter() { } bool UserEventFilter::getEnabled() const { return _enabled; } void UserEventFilter::setEnabled(const bool enabled) { if(_enabled != enabled) { _enabled = enabled; emit enabledChanged(_enabled); } } bool UserEventFilter::processKeyPress(QEvent *event) { QKeyEvent *e = static_cast<QKeyEvent *>(event); QMLKeyEvent ke(*e, e->nativeScanCode()); ke.setAccepted(false); emit keyPressed(&ke); emit userEventOccurred(); return ke.isAccepted(); } bool UserEventFilter::processKeyRelease(QEvent *event) { QKeyEvent *e = static_cast<QKeyEvent *>(event); QMLKeyEvent ke(*e, e->nativeScanCode()); ke.setAccepted(false); emit keyReleased(&ke); emit userEventOccurred(); return ke.isAccepted(); } bool UserEventFilter::processMouseButtonPress(QEvent *event) { QMLMouseEvent me(*static_cast<QMouseEvent *>(event)); me.setAccepted(false); emit mousePressed(&me); emit userEventOccurred(); return me.isAccepted(); } bool UserEventFilter::processMouseButtonRelease(QEvent *event) { QMLMouseEvent me(*static_cast<QMouseEvent *>(event)); me.setAccepted(false); emit mouseReleased(&me); emit userEventOccurred(); return me.isAccepted(); } bool UserEventFilter::processMouseMove(QEvent *event) { QMLMouseEvent me(*static_cast<QMouseEvent *>(event)); me.setAccepted(false); emit mouseMoved(&me); emit userEventOccurred(); return me.isAccepted(); } bool UserEventFilter::eventFilter(QObject * obj, QEvent * event) { Q_UNUSED(obj); if(_enabled) { switch(event->type()) { case QEvent::KeyPress: return processKeyPress(event); break; case QEvent::KeyRelease: return processKeyRelease(event); break; case QEvent::MouseButtonPress: return processMouseButtonPress(event); break; case QEvent::MouseButtonRelease: return processMouseButtonRelease(event); break; case QEvent::MouseMove: return processMouseMove(event); break; default: break; } } return QObject::eventFilter(obj, event); } @
  • Object reference between two files over thrid

    2
    0 Votes
    2 Posts
    855 Views
    T
    The ids visible in ButtonBar are only the ids defined in ButtonBar or parents of ButtonBar. InfoView is a sibling in this case, so ids defined in InfoView will not be visible in ButtonBar. You need to forward it with properties. If InfoView's id view3d is to be visible to ButtonBar, add a property to ButtonBar: @property Item view3d@ This should also be exposed from InfoView so that main.qml will look like this: @main.qml : Column { InfoView { id : info } ButtonBar { view3d: info.view3d } }@
  • Random height property

    1
    0 Votes
    1 Posts
    563 Views
    No one has replied
  • Share data between dialogs

    4
    0 Votes
    4 Posts
    1k Views
    Q
    Hi. You can use "signal and slots":http://qt-project.org/doc/qt-5.0/qtcore/signalsandslots.html for that.
  • Multiple meshes or different colored vertex sets on a single QQuickItem?

    2
    0 Votes
    2 Posts
    616 Views
    T
    The QSGNode that you create in updatePaintNode() may have as many children (with their own geometries) as you'd like.
  • Advice for doing a slot-machine animation

    5
    0 Votes
    5 Posts
    2k Views
    F
    FYI, just today I found an example using PathView that kind of looks like a slot-machine. It's in the new online QML book (best QML reference I've found): http://qmlbook.org/ch06/index.html#the-pathview. You may consider adapting the code in the example for your needs.
  • QML graph example with x/y axis

    1
    0 Votes
    1 Posts
    566 Views
    No one has replied
  • UML For QML

    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • How to pass ListModel data to C++ function

    2
    0 Votes
    2 Posts
    1k Views
    p3c0P
    Hi, You can iterate and add the model data into an array and pass that array as QVariantList to the C++ function.
  • Animate smoothly to an specific index

    2
    0 Votes
    2 Posts
    886 Views
    K
    I do not know about PathView but ListView has transition properties that hold the animations that are used in response to changes to the model. For example "ListView.move":http://qt-project.org/doc/qt-5.1/qtquick/qml-qtquick2-listview.html#move-prop.
  • 0 Votes
    3 Posts
    948 Views
    shavS
    [quote author="Vincent007" date="1387375127"]Try Qt example. examples\quick\models\abstractitemmodel[/quote] Thanks I will check!
  • ListView is updated wrong when custom QSortFilterProxyModel changes

    1
    0 Votes
    1 Posts
    2k Views
    No one has replied
  • [SOLVED] Howto use BusyIndicator?

    2
    0 Votes
    2 Posts
    1k Views
    O
    Hi! In the meantime I have found a solution: @ import QtQuick 2.2 import QtQuick.Controls 1.1 Rectangle { id: main width: 360 height: 360 BusyIndicator { id: indicator anchors.centerIn: parent running: false } MouseArea { anchors.fill: parent onClicked: { indicator.running = true timer.start() } } Timer { id: timer repeat: false onTriggered: fct() } function fct(){ console.log(fib(35)) indicator.running = false } function fib(n){ if (n === 0 || n === 1){ return 1 } else { return fib(n-1) + fib(n-2) } } } @ Best regards, Oliver.
  • [Solved] Is it possible? I want to paint on QGraphicsScene !!HELP..

    3
    0 Votes
    3 Posts
    1k Views
    N
    hey thanku :)