qtquick2

How to redirect qml's console.log() to cpp stdout

两盒软妹~` 提交于 2019-12-07 15:07:52
问题 I am using qml( qtCreator ) and cpp (visual studio). Usually the error messages are shown to the console, both from cpp and qml. My requirement is that I should not have a console. So I wrote a window application. But when a flag has been set, I should launch a console. And show the corresponding error messages there. I have used the following code in a function to set up this. HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE); int hCrt = _open_osfhandle((long) handle_out, _O_TEXT); FILE*

StackView: storing components along with their items

落爺英雄遲暮 提交于 2019-12-07 09:14:27
Consider the following code: StackView { id: stack } Component { id: componentFooBar FooBar {} } ... stack.push({item: componentFooBar}) In the example above, according to the Qt source and documentation, after componentFooBar is pushed to the stack its inner item ( FooBar ) is loaded and pushed to the top of the inner stack. And if I want to access stack head (either by pop() or get(0) ), I'll get FooBar instance, not its Component . So for Qml StackView there's no invariant like stack.push(X) X === stack.pop() Is there any way to access pushed Component s? The only idea I have for now is to

How to make a transparent window with Qt Quick 2.0

南笙酒味 提交于 2019-12-07 08:35:52
问题 I've already know how to make a transparent window with Qt Quick 1.0.But I started to use Qt 5.0 and Qt Quick 2.0 recently and didn't know how to do with it. setAttribute setWindowFlags setStyleSheet The functions above are removed from the QtQuick2ApplicationViewer(QQuickView). So I wonder whether I can make a transparent window with Qt Quick 2 or not (is it because that it's based on OpenGL?). 回答1: Look here for a possible solution: http://code.google.com/p/quickwidget/ But, with Qt 5.3 ,

How can I get transform matrix for QQuickItem?

倖福魔咒の 提交于 2019-12-07 06:13:51
问题 I worked for a long time with QGraphicsItem and it has transform() function. Now I wont to do same thing with QQuickItem but unfortunately it misses transform() . So my question - how can I get transform matrix for QQuickItem ? 回答1: Actually the QQuickItem provides the transform() method, however it returns the list of all transformations assigned to given item. It is because multiple transformations can be assigned to a single Item . The return type of QQuickItem::transform is

How to set currentIndex of SwipeView to currentIndex of TabBar “by reference” after going to specific page?

╄→гoц情女王★ 提交于 2019-12-07 04:18:54
问题 I'm getting started with QtQuick Controls 2.0. I have experience with C++ and a small amount of experience with Qt, but I have not worked with QML before. I have a TabBar and a SwipeView that are linked to each other. What I mean by this is that when you select a page on the TabBar , the SwipeView goes to that page. When you swipe to a page from the SwipeView , the TabBar updates itself to reflect that. As a learning exercise, I decided to create a button that would send the user to the

System tray icon without widgets

99封情书 提交于 2019-12-07 01:00:29
问题 I'm wondering if there's a way to implement system tray icon + menu functionality without widgets module? 回答1: Qt 5.8 introduces a SystemTrayIcon QML type in the experimental Qt Labs Platform module, as part of the Qt Quick Controls 2 offering. It uses a native implementation directly from the Qt Platform Abstraction layer where available, and Qt Widgets as a fallback on other platforms. 来源: https://stackoverflow.com/questions/41095630/system-tray-icon-without-widgets

Are “var” and “variant” the same thing?

淺唱寂寞╮ 提交于 2019-12-06 20:32:59
问题 From what I understand, to make a property an array in QML you must specify it as the type variant or var : property var myArray:[] And this appears to be exactly the same as: property variant myArray:[] Is this true? 回答1: According to the Qt 5.0 variant documentation: The variant type is a generic property type. It is obsolete and exists only to support old applications; new applications should use var type properties instead. So yes, it is the same, but you should always stick to var

Qt invoking qml function with custom QObject type

折月煮酒 提交于 2019-12-06 18:56:31
I want to invoke a qml method from c++ passing as a parameter a custom type. This is my custom type (*Note that all the code I post is not exactly what i'm using, i've extracted the relevant parts, so if you try to compile it is possible that some changes have to be made) Custom.h class Custom : public QObject { Q_OBJECT Q_PROPERTY(QString ssid READ getSSID WRITE setSSID) public: Q_INVOKABLE const QString& getSSID() { return m_ssid; } Q_INVOKABLE void setSSID(const QString& ssid) { m_ssid = ssid; } } private: QString m_ssid; }; Q_DECLARE_METATYPE(NetworkInfo) Custom.cpp Custom::Custom():

How to find the latest versions of all QML modules

為{幸葍}努か 提交于 2019-12-06 17:55:02
问题 Usually my QML files start with import QtQuick 2.4 and other imports. How can I know which is the latest version of the imported modules without having to guess by type and build? 回答1: You basically don't have to know. By importing a particular version, you merely declare that you don't need the additional functionality of any potentially newer version. That doesn't mean that you won't use a newer version if one is available - it simply means that your code will refuse to run if only an older

What would be the way to take a screenshot of a particular Item in QML?

别说谁变了你拦得住时间么 提交于 2019-12-06 16:00:10
问题 I know how to take a screenshot of the whole window in QML. I have a Video element in the QML window. That video is shown in a Rectangle . What would be the way to take a screenshot of that Rectangle rather than the whole window? 回答1: Take a look at Item 's grabToImage method. bool grabToImage(callback, targetSize) Grabs the item into an in-memory image. The grab happens asynchronously and the JavaScript function callback is invoked when the grab is completed. Use targetSize to specify the