跳到內容

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k 主題 77.4k 貼文
  • Bug ? MouseEvent generates Canceled signal if not accepted

    2
    0 評價
    2 貼文
    903 瀏覽
    p3c0P
    Hi, bq. If in onPressed() handler I set accepted to false this cause Canceled signal to be generated ! If we would follow documentation this must just propagate mouse event to another MouseArea It will not as "propagateComposedEvents":http://doc.qt.io/qt-5/qml-qtquick-mousearea.html#propagateComposedEvents-prop only works for composed events and pressed is not a composed event. From the Doc: bq. MouseArea contains several composed events: clicked, doubleClicked and pressAndHold. These are composed of basic mouse events, like pressed, and can be propagated differently in comparison to basic events.
  • Flickable DragOverBounds : amount of overshoot

    1
    0 評價
    1 貼文
    378 瀏覽
    尚無回覆
  • [resolved] Dynamic height in ListView?

    4
    0 評價
    4 貼文
    16k 瀏覽
    G
    Here is another solution which solves the problem: @ListView { id: myListView onCountChanged: { /* calculate ListView dimensions based on content */ // get QQuickItem which is a root element which hosts delegate items var root = myListView.visibleChildren[0] var listViewHeight = 0 var listViewWidth = 0 // iterate over each delegate item to get their sizes for (var i = 0; i < root.visibleChildren.length; i++) { listViewHeight += root.visibleChildren[i].height listViewWidth = Math.max(listViewWidth, root.visibleChildren[i].width) } myListView.height = listViewHeight myListView.width = listViewWidth } } @ "onCountChanged" event fires after all delegate items are rendered so their sizes are known by that moment. This code works with Qt 5.4.0.
  • Simulating mouse events for QML

    6
    0 評價
    6 貼文
    8k 瀏覽
    P
    Hi, I have the same issue. Seems this is a bug in Qt and no one cares about to fix it https://bugreports.qt.io/browse/QTBUG-37545
  • C++ custom treemodel viewing in QML

    9
    0 評價
    9 貼文
    2k 瀏覽
    D
    bq. n that case I think you could use standard ListView, standard 1D list, create separate ListView for each “level” of detail this is also what i was thinking. But the question is: for example, How would i make a listview that show only the top level items of my treemodel so that only the children of the rootitem are shown (the groups).. if i know this i can make different lists that show specific details of certain items just like you said. I would be able to select a folder and make a list that shows all the children of the folder (all the files). oh and thank you again, i cannot say how much i apreciate the help because i always try to figure stuff out completely on my own
  • Change child windows element text or proporty

    4
    0 評價
    4 貼文
    974 瀏覽
    mehmetakM
    thx sierdzio , thx p3c0 i solved problem.
  • ApplicationWindow.qml - hasColor property ( Qt > 5.3 )

    3
    0 評價
    3 貼文
    677 瀏覽
    M
    ok thanks! :)
  • [Solved] QML template exchange

    2
    0 評價
    2 貼文
    755 瀏覽
    SGaistS
    Hi, The wiki could be used for that
  • Dialog setting the icon?

    4
    0 評價
    4 貼文
    984 瀏覽
    SGaistS
    Sorry, I don't know for a Dialog in particular but you can do it on the viewer you are using to show your QML
  • Memory leak when passing data between C++ objects and QML

    7
    0 評價
    7 貼文
    7k 瀏覽
    T
    Our embedded application is deployed on an Angstrom distribution limited to 256MB of memory. The longer the application runs, the more memory that is consumed (several inputs require screen updates at least once a second). The issue is that the garbage collector would not run before the OS starts killing processes in an effort to free memory. As mentioned in a previous post, adding calls to gc() does provide a functional workaround. I'm not overly enamored with this solution. Is there a way to configure the garbage collector watermark? I'm providing a gross example which causes a memory increase large enough to trigger garbage collection in a matter of minutes running on a PC vs. a day or so running our application. It also shows the way data is being passed from c++ to QML in our application (and no, not at 1000 times per second, example purposes only). Perhaps someone can provide an alternate approach. @// // ApplicationData.h // #ifndef APPLICATIONDATA_H #define APPLICATIONDATA_H #include <QtGui> class ApplicationData : public QObject { Q_OBJECT public: ApplicationData(); Q_INVOKABLE QString getTemperature() const { return temperature; } public slots: void update(); signals: void temperatureChanged(); private: QString temperature; }; #endif // APPLICATIONDATA_H@ @#include "ApplicationData.h" ApplicationData::ApplicationData() { // timer used to quickly demonstrate memory usage QTimer *timer = new QTimer(this); timer->start(1); connect(timer, SIGNAL(timeout()), this, SLOT(update())); } // // ApplicationData.cpp // void ApplicationData::update() { temperature = "00000000001111111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999000000000011111111112222222222333333333344444444445555555555666666666677777777778888888888999999999900000000001111111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999"; emit temperatureChanged(); } @ @// // main.cpp // #include <QApplication> #include <QQmlApplicationEngine> #include <QQmlContext> #include <ApplicationData.h> int main(int argc, char *argv[]) { QApplication app(argc, argv); ApplicationData data; QQmlApplicationEngine engine; engine.rootContext()->setContextProperty("applicationData", &data); engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); return app.exec(); } @ @// // main.qml // import QtQuick 2.3 import QtQuick.Controls 1.2 ApplicationWindow { visible: true width: 640 height: 480 title: qsTr("Memory Example") Text { id: temperature text: applicationData.getTemperature() Connections { target: applicationData onTemperatureChanged: { temperature.text = applicationData.getTemperature() } } } } @ Thanks in advance for any input. Tim
  • Qt Quick custom control (window to display images)

    2
    0 評價
    2 貼文
    1k 瀏覽
    E
    This is where the widtget is used: @ // Lib/Qt measure example // // matching.cpp : Implementation of the class Matching // #include "matching.h" #ifdef Q_WS_X11 #include <X11/Xlib.h> #endif #include <qfont.h> #include <qlayout.h> #include <qstring.h> #include <qcursor.h> // Constructor: create GUI Matching::Matching(QWidget *parent) : QWidget(parent) { WindowIDBuf = -1; ... // Disp: Father widget for Lib window in HBoxDispAndButtons Disp = new QLibWindow(this); Disp->setMinimumSize(50,50); // Buttons in HBoxDispAndButtons QVBoxLayout *Buttons = new QVBoxLayout; ... } // The destructor is called when the user closes the application by clicking // on the close button in the window manager decoration. Matching::~Matching(void) { using namespace LibCpp; // Close all allocated Lib resources. CloseWindow(WindowIDBuf); killTimer(Timer); } // Initialize Lib windows void Matching::InitWin(void) { using namespace LibCpp; // Initialize framegrabber InitFg(); WindowWidth = Disp->width(); WindowHeight = Disp->height(); // Open a Lib buffer window that will be used to program a flicker-free // display of the results. OpenWindow(0,0,WindowWidth,WindowHeight,0,"buffer","",&WindowIDBuf); SetPart(Disp->WindowID(),0,0,Height-1,Width-1); SetPart(WindowIDBuf,0,0,Height-1,Width-1); SetLineWidth(Disp->WindowID(),3); SetLineWidth(WindowIDBuf,3); DispObj(Image,Disp->WindowID()); } // This slot is called whenever the application's main widget is resized. // The member function QLibWindow::resizeEvent() of the QLibWindow // widget is called before this function, thus only the buffer window needs // to be resized at this point. void Matching::resizeEvent(QResizeEvent*) { using namespace LibCpp; if (WindowIDBuf>0) { // Determine the new dimensions of the QLibWindow widget. // We save the new dimensions for later use in CopyRectangle. WindowWidth = Disp->width(); WindowHeight = Disp->height(); SetWindowExtents(WindowIDBuf,0,0,WindowWidth,WindowHeight); // Display the current image. Note that this will slow down the resize // operation considerably. DispObj(Image,Disp->WindowID()); } } // This function is called continously after Timer is started in ::Start() void Matching::timerEvent(QTimerEvent*) { StartMatching(); } // Start continuous matching void Matching::Start(void) { StartButton->setEnabled(false); StopButton->setEnabled(true); // Start Timer -> ::timerEvent() is called continously Timer = startTimer(20); } // Stop continuous matching void Matching::Stop(void) { StartButton->setEnabled(true); StopButton->setEnabled(false); // Kill Timer killTimer(Timer); } @
  • Qt Quick 2: Components to show map tiles?

    1
    0 評價
    1 貼文
    518 瀏覽
    尚無回覆
  • Q_PROPERTY not working properly on linux distros

    3
    0 評價
    3 貼文
    1k 瀏覽
    R
    @lynic thanks, I run qmake to create the specific Makefile, then i execute make and get the executable file.
  • Cache Image in QML code

    2
    0 評價
    2 貼文
    2k 瀏覽
    GianlucaG
    I didn't do it, but if I would I'll do in the following way: Into QML Image, I'll use the scheme for ImageProvider: @ Image { source: "image://Cached/image1.png" } @ In the QQuickImageProvider: if the image1.png is in the cache, it'll return it. if the image1.png is not in the cache, it'll return an predefined image with "loading image". in both case, I'll notify to an object for handling cache that image1.png has been requested. In a CacheHandler object: for each notification of request, I'll do any network stuff for checking if the image1.png has to been downloaded for the first time or just need to be updated after each new updating of cache items, I'll broadcast a signal for refreshing the Image QML elements In QML Image, I'll handle in someway the refreshing of the image connecting the signal of CacheHandler with a function for updating the image.
  • Is it impossible main.qml in qml.qrc access other qrc image resource?

    2
    0 評價
    2 貼文
    947 瀏覽
    sierdzioS
    Try with ":/icon/some.png", or change the prefix inside icon.qrc to be the same as in qml.qrc.
  • Scroll view

    28
    0 評價
    28 貼文
    8k 瀏覽
    p3c0P
    anchor it to left or right as required.
  • Set theme color of applications

    2
    0 評價
    2 貼文
    526 瀏覽
    D
    Hey, sorry i don't want to troll you but i read several threads from you and nearly every single post can answered with google, the qt documentation, the qt examples or a little search in this great forum. Have u ever tried this?
  • Multiple "when"-conditions for a State

    1
    0 評價
    1 貼文
    336 瀏覽
    尚無回覆
  • [SOLVED] How to define your own subclass of QChart(C++) as a QML ItemType

    8
    0 評價
    8 貼文
    4k 瀏覽
    JKSHJ
    I'm glad to hear you've found a solution. [quote author="hghgi1" date="1424089426"]But I still want to know what do I leave out if I go back to QtQuick 1.0, and why doesn't QtQuick 2.3 support such features? Wanna know some pro/cons for the two solutions. If I should guess why can't 2.3 support what 1.0 supported is because QWidget doesn't really use OpenGL and GPU features, but this is only a guess.[/quote]Your guess is correct. Qt Quick 1 is simply a wrapper around the "Graphics View Framework":http://doc.qt.io/qt-5/graphicsview.html, which is based on QWidgets and renders graphics using the CPU. Qt Quick 2 is a complete rewrite using new technology, which is based on OpenGL and renders graphics using the GPU. Its internals do not share anything in common with QWidgets. It has much better performance than Qt Quick 1 due to hardware-accelerated graphics, as well as a custom JavaScript engine that is optimized for transferring data between C++ and QML. (You might not need to worry about the graphics performance though)
  • How to check if a delegate is endmost in a ListView?

    4
    0 評價
    4 貼文
    869 瀏覽
    p3c0P
    You're Welcome :) You can mark the post as solved by editing the post title and prepending [solved].