Skip to content
  • Why can't I print the score in text feild?

    Unsolved QML and Qt Quick qml javascript qtcreator
    3
    0 Votes
    3 Posts
    660 Views
    Pradeep P NP
    Hi @newbiSoso There are some modifications in your code which i tried. Rectangle{ id: rect width: 50 height: width color: squareColor radius: 10 } In QML you cant compare color with string as its HEX value So make these changes. MouseArea{ anchors.fill: parent onClicked: { if (squareColor === "cyan") root.score = root.score + tttt.text; else if (squareColor === "red") root.score = root.score - tttt.text; } } You are doing root.score + tttt.text which will be considered as string concatenation so your score will be something like below image. [image: 7b51ca38-9d73-4416-b2c3-9a23d4d620ad.png] I dint get error as you mentioned. but please avoid using string concatenation for int +/- functionality Please use the value from model txt from your code to avoid string concatenation All the best.
  • 0 Votes
    14 Posts
    4k Views
    SGaistS
    Anyone can contribute to the documentation, the code, etc. You have to follow the procedures and rules but it's not some walled garden.
  • 0 Votes
    1 Posts
    615 Views
    No one has replied
  • 0 Votes
    4 Posts
    3k Views
    devDawgD
    Okay, so I have made a fair amount of progress since I last commented. For either of my strategies, I would come across this Javascript error: TypeError: property of object such and such is not a function. I realized, with the help of a colleague, that my assignment of the model was what was screwing me. Instead of creating a .qml file to serve as my custom model, I was using the length of a QVector within a context property from C++, meaning that my model was nothing but a number! Hence, zero access to the Javascript array functions. So, my new approach is pre-load my models in .qml, rather than constantly make Q_INVOKABLE method calls from a C++ context property class.
  • How to connect to databases in QML

    Solved QML and Qt Quick qml c++ javascript mysql sql server
    3
    0 Votes
    3 Posts
    5k Views
    R
    @SGaist , thanks
  • javascript documentation

    Solved QML and Qt Quick qt widget documentation qml qt quick javascript
    5
    0 Votes
    5 Posts
    2k Views
    JKSHJ
    @tansgumus said in javascript documentation: Is there any plan to cover JavaScript docs by Qt? Currently not. As I mentioned, the Qt Project has no control over the JavaScript API, so it will not document the JavaScript API either. However, QML classes and methods are fully documented -- if you find something missing, please file a bug report.
  • 0 Votes
    4 Posts
    4k Views
    6thC6
    Well, there is some it seems... just not all? I note there's quite a few comments: // ECMAScript 6 @: http://doc.qt.io/qt-5/qtqml-javascript-functionlist.html While I've not used it - that page has: map(callbackfn [, thisArg]) but not Set.. not sure if that helps...
  • I can not import anything in qml

    Unsolved QML and Qt Quick qml javascript qt5 import
    3
    0 Votes
    3 Posts
    2k Views
    Dante LeonciniD
    try to create a qmldir file, but it did not work look for the error but I found nothing that serves me. I do not know if it has to do with the fact that I'm not using a qrc file. in the ".pro" file, add a line to copy and paste the "qml" folder into the compiled directory. that's because I want the code jv and qml can be edited with any editor in the final version #Copia la carpeta "qml" dentro de la carpeta build copydata.commands = $(COPY_DIR) $$PWD/qml $$OUT_PWD first.depends = $(first) copydata export(first.depends) export(copydata.commands) QMAKE_EXTRA_TARGETS += first copydata
  • 0 Votes
    2 Posts
    2k Views
    J
    Anyone has any idea?
  • 0 Votes
    24 Posts
    17k Views
    JonBJ
    @ShivaHaze @ShivaHaze said in 'evaluateJavaScript()' doesn't return any value. (content position on page wanted): You are a god to me - Thanks so much! I think you might have meant "good" rather than "god" ;-) I am very pleased this approach has worked for you. It is potentially useful for me to know for my own work one day. Had I realized you had not tried the "delay" principle earlier, we would have got there quicker. The actual implementation of the delay loop is "naughty". It will mean that your application is "running busily" (i.e. using CPU time, potentially blocking other applications) for most of 1 second. If an expert here looks at it, please don't shout at me! Like I said, I got it from elsewhere as "quick & dirty". For your purposes it's probably fine, and we achieved it without you having to do slots & signals which you were not keen on learning at this stage. If you feel like you want to improve/experiment, in the same stackoverflow thread have a look at https://stackoverflow.com/a/3756341/489865, leveraging QWaitCondition, whose description sounds like it should have the same effect without the "busy blocking": class SleepSimulator{ QMutex localMutex; QWaitCondition sleepSimulator; public: SleepSimulator::SleepSimulator() { localMutex.lock(); } void sleep(unsigned long sleepMS) { sleepSimulator.wait(&localMutex, sleepMS); } void CancelSleep() { sleepSimulator.wakeAll(); } }; Certainly I would try it. If you copied that class into your code, you would call it (I assume) via: SleepSimulator* sleep = new SleepSimulator(); sleep->sleep(1000); delete sleep; Now I think you can get down to the real coding you want to do for your application! Best of luck.
  • 0 Votes
    2 Posts
    2k Views
    M
    I believe this is a bug in Qt Creator so I filed a bug report about this issue: https://bugreports.qt.io/browse/QTCREATORBUG-18666
  • QML - Javascript: Does Javascript support EcmaScript 6?

    Unsolved QML and Qt Quick qml javascript es6
    9
    0 Votes
    9 Posts
    12k Views
    S
    @GrecKo Never mind, I found your SO post explaining that I need to download the Qt Creator 4.9.0-beta2. That supports the new syntax.
  • Non-blocking QML

    Moved Solved QML and Qt Quick javascript javascript qml c++ asynchronous promise
    4
    1 Votes
    4 Posts
    6k Views
    romsharkovR
    After a detailed research of various asynchronous techniques such as Promises, Futures, Tasks and Reactive Extensions we came with a new paradigm that solved all our asynchronous problems very elegantly: The Streams Paradigm It's inspired by the reactive approach, though superior in many aspects such as abstraction, abortion, resumables etc. It's a completely rethought way of writing declarative code, making complex asynchronous operations and transactions (and probably even concurrency) a piece of cake! Nearly everything can be represented, thus abstracted away by a stream.. UI Elements Sockets Requests (HTTP etc.) Calculations the list goes on... This way streams become a consistent protocol of asynchronous and concurrent communication between various application components ranging from the UI frontend to the networked backend. We published the first beta release of a QML implementation with a working example aboard, be sure to check it out! https://qbeon.github.io/QuickStreams/
  • 0 Votes
    1 Posts
    1k Views
    No one has replied
  • 0 Votes
    2 Posts
    2k Views
    T
    Well one way to do it is to use QWebEnginePage::runJavaScript but be careful it executes asynchronously! http://doc.qt.io/qt-5/qtwebenginewidgets-qtwebkitportingguide.html then in your javascript - find IMG element by id/class/whatever and set its contents like an embedded image e.g. change src to src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==' this is example 1x1 pixel black dot image you'll have to substitute with your own image data base64 encoded and of course change image format if you're not using png to data:image/jpg(whatever)
  • 0 Votes
    1 Posts
    757 Views
    No one has replied
  • Data exchange between Java Script and Qt C/C++

    Unsolved General and Desktop javascript c++
    4
    0 Votes
    4 Posts
    2k Views
    p3c0P
    @Briddl Great!. Btw. why do you want to implement logic in JS ?
  • 0 Votes
    6 Posts
    3k Views
    sierdzioS
    @Stefan-Monov76 said in What are those string "name" properties set to various objects in Qt Canvas3D code?: I just don't know what the purpose of setting it is. Me neither, sorry. The only thing that I gather from the docs is that all Canvas3D objects have name parameter, much like QObject/ QML QtObject, so perhaps it can be used to search objects by name. It's only a guess, though.
  • Best approach for web applications

    Unsolved General and Desktop webserver websocket html5 javascript remote
    15
    1 Votes
    15 Posts
    11k Views
    M
    @kshegunov ok now I understand! Thanks!
  • How to pass and modify Javascript object in C++?

    Unsolved QML and Qt Quick qml javascript c++
    5
    0 Votes
    5 Posts
    2k Views
    D
    QmlHelper is a class made available to qml using QDeclarativeContext::setContextProperty(const QString & name, QObject * value) Is using qmlRegisterType the only solution? I'd prefer to avoid as that would create other problems to solve in my project.