Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k Topics 77.4k Posts
  • Problem with Qt5, QML and global variables in javascript file

    11
    0 Votes
    11 Posts
    4k Views
    R
    Eventually, Loader help me fix the issue, but I still don't understand why the JS doesn't work for Item in delegate. It seems more like a BUG.
  • Qml project

    2
    0 Votes
    2 Posts
    670 Views
    sierdzioS
    Just like any other Qt project. Instead of creating a widget, though, use QQuickView to run QML code. Or, if you prefer, you can copy the project template from Qt Creator.
  • Menu in Widget embedded QQuickView

    3
    0 Votes
    3 Posts
    3k Views
    B
    As requested main.cpp @ #include <QApplication> #include <QMainWindow> #include <QQuickView> int main(int argc, char *argv[]) { QApplication app(argc, argv); QMainWindow mainWindow; QQuickView* viewer = new QQuickView(); viewer->setResizeMode(QQuickView::SizeRootObjectToView); QWidget* container = QWidget::createWindowContainer(viewer, &mainWindow); container->setFocusPolicy(Qt::StrongFocus); viewer->setSource(QUrl(QStringLiteral("qrc:/main.qml"))); mainWindow.setCentralWidget(container); mainWindow.show(); return app.exec(); } @ main.qml @ import QtQuick 2.2 import QtQuick.Controls 1.2 Rectangle { width: 1024 height: 768 Menu { id: menu title: "File" MenuItem { text: "One"} MenuItem { text: "Two"} MenuItem { text: "Three"} } MouseArea { anchors.fill: parent onClicked: menu.popup() } } @ Outputs: void QWindow::setTransientParent(QWindow*) QQuickView(0x6a7270) must be a top level window. And menu ends up being placed at what looks like global screen space + offset.
  • Could not find the executable please find one .

    5
    0 Votes
    5 Posts
    6k Views
    dheerendraD
    You are building the plugin. This is QmlPlugin. This QmlPlugin is used in other project inside the other project. Please look at how QmlExtension Plugins work. This will help you to use the project you are building. Since it is plugin, it asking the executable to run. So don't run the project directly. It is not meant to be like that.
  • How can I use Layouts in ' Qt Quick ' ?

    3
    0 Votes
    3 Posts
    911 Views
    Y
    Thanks JKSH I used Qt Quick Layouts and the QML Button. Actually the QML Button is much more easier tan creating my own button .
  • Refresh QML Image

    5
    0 Votes
    5 Posts
    5k Views
    F
    Try to extract image source to property. than change this property. @ property string src: "img.png" Image{ source: src function reload() { src = "img1.png" } @
  • QtQuick 2 multiple processes

    4
    0 Votes
    4 Posts
    1k Views
    JKSHJ
    [quote]I see, I can’t seem to get a QWindow to be actually INSIDE another one though, maybe I’m going at it wrong.[/quote]Try setting the window's parent. Child windows will be drawn within the boundaries of their parent.
  • Reference Error

    6
    0 Votes
    6 Posts
    2k Views
    D
    so I was able to fix everything I guess it just needed some added bits of code. I was following the guide from the examples and at certain points it gets those errors until the whole code is completed. I'm not sure if that is some thing I should be wary of in the future. @import QtQuick 2.0 import QtQuick 1.1 Rectangle { id: root property bool showDate: true property bool showSeconds: true property string currentTime property string currentDate // the sizes are in proportion to the hight of the clock. // There are three borders, text and date. // 3*borderProportion+timeTextProportion+dateTextProportion has to be 1.0 property real borderProportion: 0.1 property real timeTextProportion: 0.5 property real dateTextProportion: 0.2 property string textColor: "red" property string timeFormat: "hh :mm" property string dateFormat: "dd/MM/yy" height:120 width:250 color: "transparent" // returns formated time and date function getFormattedDateTime(format) { var date = new Date return Qt.formatDateTime(date, format) } function updateTime() { root.currentTime = "<big>" + getFormattedDateTime(timeFormat) + "</big>" + (showSeconds ? "<sup><small> " + getFormattedDateTime("ss") + "</small></sup>" : ""); root.currentDate = getFormattedDateTime(dateFormat); } Image { id: background source: "File:/home/phoenix/QtExamples/content/resources/light_background.png" fillMode: "Tile" anchors.fill: parent onStatusChanged: if (background.status == Image.Error) console.log (qsTr("Background image \"") + source + qsTr("\" cannot be loaded")) } FontLoader { id: ledFont // unfortunately, the font will not load on a Symbian device, // and the default font will be used: // http://bugreports.qt-project.org/browse/QTBUG-6611 // The bug should be fixed in 4.8 source: "File:/home/phoenix/QtExamples/content/resources/font/LED_REAL.TTF" onStatusChanged: if (ledFont.status == FontLoader.Error) console.log("Font \"" + source + "\" cannot be loaded") } Timer { id: updateTimer running: Qt.application.active && visible == true repeat: true triggeredOnStart: true onTriggered: { updateTime() // refresh the interval to update the time each second or minute. // consider the delta in order to update on a full minute interval = 1000*(showSeconds? 1 : (60 - getFormattedDateTime("ss"))) } } // trigger an update if the showSeconds setting has changed onShowSecondsChanged: { updateTime() } Column { id: clockText anchors.centerIn: parent spacing: root.height*root.borderProportion Text { id: timeText textFormat: Text.RichText text: root.currentTime font.pixelSize: root.height*root.timeTextProportion font.family: ledFont.name // use "Series 60 ZDigi" on Symbian instead font.bold: true color: root.textColor style: Text.Raised styleColor: "black" } Text { id: dateText text: root.currentDate color: root.textColor anchors.horizontalCenter: parent.horizontalCenter font.family: ledFont.name // use "Series 60 ZDigi" on Symbian instead font.pixelSize: root.height*root.dateTextProportion visible: root.showDate style: Text.Raised styleColor: "black" } } } @
  • 0 Votes
    1 Posts
    584 Views
    No one has replied
  • QML context of dynamically generated items

    5
    0 Votes
    5 Posts
    2k Views
    T
    I have defined the objectName in MyTab.qml. findChildren<>() should return a list of all Items with the given objectName. Any suggestions how I can access the TabController within @var a_tab_controller = a_tab.TabController@ which returns some @[object Object]@ ?
  • [QQuickPaintedItem] Problem with drawing text and lines

    4
    0 Votes
    4 Posts
    2k Views
    M
    Yep, thanks a lot. I've tried float coordinates but it didn't help. But I found that if I disable antialiasing (remove this line painter->setRenderHint(QPainter::Antialiasing); ), the line looks ok.
  • 'pure' C++ and QML

    4
    0 Votes
    4 Posts
    2k Views
    F
    It would be better if you add Qt spices into your 'pure' C++ to integrate with QML, rather than introducing another layer of facade/adapter. I believe you don't want to keep writing that extra layer in your future projects. You can still keep your methods and logic but of course some modifications are need, like: inheriting your class from QObject change some 'pure' data type into Qt's flavor, eg: change your existing string to QString. make some methods become Qt slots so that Javascript in QML can call them You can check out the WeatherInfo example which illustrates the integration of C++ and QML: http://qt-project.org/doc/qt-5/qtpositioning-weatherinfo-example.html You should have a good read on "Integrating QML and C++":http://qt-project.org/doc/qt-5/qtqml-cppintegration-topic.html too.
  • Overwriting the existing property with alias

    2
    0 Votes
    2 Posts
    605 Views
    dheerendraD
    alias 'colour' actually refers to the blue rectangle colour. colorrectangle should be 'red'. It will not change to blue as it is just a alias. It should have been set to red internally. Since it is not setting to 'red', I feel it is bug.
  • Project files in q Qt application combining both C++ and QML

    2
    0 Votes
    2 Posts
    690 Views
    dheerendraD
    You can look at the example directory in your Qt installation. Examples/Qt-5.3/quick/controls/calendar
  • [Solved] Singleton Signal Propogation Question

    2
    0 Votes
    2 Posts
    996 Views
    D
    I went with my own solution setting an id for each query that I make to the db and then checking that id to restrict signal handling to a particular handler.
  • QML loaded from plugin cannot reference local types

    4
    0 Votes
    4 Posts
    1k Views
    G
    ok, I've found something like a solution. The QML references I pass to the Loader must be relative to the root of the project. If that is the case, everything works. So simply saying @DynaLoader.show = "/Bla.qml"@ causes Bla.qml and all nested components to be resolved correctly
  • About integrating c++ and qml

    7
    0 Votes
    7 Posts
    1k Views
    Y
    ok , what about the wrapper object when should I use it and what does it d exactly?
  • How to open a new window in Qt Quick with a mouse area signal ?

    9
    0 Votes
    9 Posts
    4k Views
    Y
    Hello , I would like to ask when should I use the qml register type and when to use the plugin. Actually the concept is new to me and I feel confused and I don't know from where to start. I watched the video of Qt developer days 2011 It is discussing this task it clarified a little bit some concepts but I still find it ambiguous . Thanks in advance.
  • Qt 5.2.1 Quick 1.1 strange behavior on Android

    1
    0 Votes
    1 Posts
    594 Views
    No one has replied
  • Problem running QML example

    3
    0 Votes
    3 Posts
    1k Views
    R
    It sounds like your problem is similar to mine (see my post from a couple of weeks ago). It was suggested that I download and use the Qt version that is not for OpenGL. I didn't do this because I use VS 2010 and the version of Qt is for VS 2013. Since you have VS 2013, you could easily check if this solves the problem.