Menu
  • HOME
  • TAGS

How to compile this qt program(There is no any pro file)?

qt,qt4,qml,qt-quick,qt3d

It does not contain any source code, just qml files. It is entirely written in interpreted QML. You would need to run the "main.qml", which is the "game.qml" here, through the qml viewer as follows: qmlviewer-qt4 game.qml or qmlviewer-qt4 game.qml These applications are installed by the qt/qtquick and qtquick1 packages...

How to set property type of qml signal?

pyqt,qml,qt-quick,qtquick2

It seems on there's indeed an error in the Qt Documentation. It is said (here) that the allowed parameter types [for signal parameters] are the same as those listed under Defining Property Attributes on this page. Yet one can define a property as follow: property list<Item> items whereas this is...

How to access the public properties of a qml page loaded through a Loader?

qt,qml,loader,qt-quick

Solution is as follows: drawLineLoaderA.source = "DrawLineLoader.qml" if (drawLineLoaderA.status == Loader.Ready) { if (drawLineLoaderA.item && drawLineLoaderA.item.lineColour) { drawLineLoaderA.item.lineColour = "black" drawLineLoaderA.item.lineDrawingSourceType = 2 } } ...

How can I reorder the items in a QML GridLayout?

qml,qt-quick,qtquick2

You can use the row and column attached properties.

Animation for Qml Loader when loader.source changes

qt,qml,qtquick2,qt-quick,qt5.4

This is one way to do it: import QtQuick 2.4 import QtQuick.Window 2.0 Window { id: window width: 400 height: 400 visible: true Loader { id: loader onSourceChanged: animation.running = true NumberAnimation { id: animation target: loader.item property: "x" from: 0 to: window.width - loader.item.width duration: 1000 easing.type: Easing.InExpo }...

QML nested properties - Cannot assign to non-existent property

qt,qml,qt5,qt-quick,qtquick2

Try replacing your nested QtObject with a qml file. For example, I replaced it with BackgroundTheme.qml, the enabled property work correctly, in a binding and without error, in main.qml BackgroundTheme.qml import QtQuick 2.0 QtObject { property color pressed: "#CCCCCC" property color enabled: "#666666" property color disabled: "#555555" } MyButtonStyling.qml import...

QtQuick: QQmlApplicationEngine failed to load component qrc:/main.qml:23 Invalid attached object assignment

c++,qt,qml,qt-quick,qt5.4

Property name should start with lowercase letter. You need to change DeltaT to deltaT. MainScreen.h Q_PROPERTY(qreal deltaT READ getDeltaT WRITE setDeltaT NOTIFY deltaTChanged) main.qml MainScreen { SequentialAnimation on deltaT { } } ...

Drawing to the left of x,y coordinates

qt,drawing,coordinates,qml,qt-quick

You can not use negative values for this purpose since negative width or height is not supported in QML. But you can use Scale type to accomplish this : Rectangle { id: rectangle1 x: 257 y: 221 width: 50 height: 50 color: "#000000" transform: Scale { origin.x: 0; origin.y: 0;...

Issue with drawing an Qml Item with raw OpenGL calls

qt,opengl,qml,qt-quick,qtquick2

The drawn rectangle is half the sizes you expect because the default coordinate range is [-1, 1], not [0, 1] as your code assumes. If you want to use [0, 1] scale, then you should appropriately set the projection matrix: glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); ...

wrong coordinates white getting real position of item relative to its parent

qt,qml,qt-quick,qtquick2

The documentation of Item proposes the mapToItem function: Maps the point (x, y) or rect (x, y, width, height), which is in this item's coordinate system, to item's coordinate system, and returns an object with x and y (and optionally width and height) properties matching the mapped coordinate. If item...

How to override signal handler of superclass component

qt,inheritance,qml,handler,qt-quick

You can define the code of the signal handler as a property in superclass and override it in the derived item: Item { property var handlerCode: function () { console.log("In Superclass") }; Thing { id: theThing; onMySignal: handlerCode() } } Overriding : Base { handlerCode: function () { console.log("In Derived...

How to Layout Contents of Window when Resizing window width?

qt,qml,qt5,qt-quick

According to the question I've assumed that you also need the ScrollBars, hence I've added the ScrollView. Even if we remove the latter, the general approach still applies. The keypoint is in dynamically recalculate the number of necessary/available rows and colums. Then we can exploit QML binding and directly set...

MouseArea event is propagated to its parent sibling. Why?

qt,qml,qt-quick,qtquick2

In your example, onExited must emits when entering ToolButton. According to MouseArea.exited(): Rectangle { width: 400; height: 400 MouseArea { id: mouseArea1 anchors.fill: parent hoverEnabled: true } MouseArea { id: mouseArea2 width: 100; height: 100 anchors.centerIn: parent hoverEnabled: true } } Moving the mouse into mouseArea2 from mouseArea1 will cause...

Checking mouse event on line in Context2d

qt,plot,qml,data-visualization,qt-quick

Unfortunately, AFAIK, you should keep track of what you draw. Canvas doesn't store drawn stuff as vector graphics(again, AFAIK), but on a raster, so there's no way to get it to tell you where the lines/points are. You could push each point you pass to ctx.moveTo and ctx.lineTo to a...

QML QQuickImageProvider creation and registration

c++,qt,qml,qt-quick

Found a solution: We can do anything with QQmlEngine right from the plugin: void initializeEngine(QQmlEngine *engine, const char *uri) { Q_UNUSED(uri); engine->addImageProvider("map", new MapImageProvider); } ...

Close and Minimise button is disabled on Linux using Qt5.3.2

c++,linux,qt,qt-quick,qt5.3

You can set the windows flag for QQuickView as : view.setFlags(Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint); ...

Align horizontalcenter in Column

qt,qml,qtquick2,qt-quick

I suppose you can use anchors.horizontalCenter for all the child items to align them with the horizontalCenter of the column given that the column has an id you can refer to.

Scaling pixel art with Qt Quick

qt,qml,scaling,qt-quick,pixelate

The image is blurry when scaled because the smooth property is true by default. Primarily used in image based items to decide if the item should use smooth sampling or not. Smooth sampling is performed using linear interpolation, while non-smooth is performed using nearest neighbor. Set it to false to...

Set rotation point of Rectangle

qt,rotation,qml,qtquick2,qt-quick

rotation property rotates item clockwise around its transformOrigin property which could be one of these nine points : So you can rotate around one of them like : Rectangle{ id: body rotation: value transformOrigin: Item.Center anchors.centerIn: parent.Center antialiasing: true } If you want to rotate around an arbitrary point you...

Сreate a copy of a rectangle in QML

qt,qml,qtquick2,qt-quick

you can create a QML object from a string of QML using the Qt.createQmlObject() and set it's x and y values to mouseX and mouseY : import QtQuick 2.3 import QtQuick.Window 2.0 Window { id : root visible: true width: 1000 height: 500 MouseArea { anchors.fill: parent onClicked:{ var newObject...

QML: set smooth painting

qt,qml,qt-quick

The property you need to set is antialiasing. This is documented here: antialiasing : bool Used to decide if the Rectangle should use antialiasing or not. Antialiasing provides information on the performance implications of this property. The default is true for Rectangles with a radius, and false otherwise. (Emphasis mine.)...

qml: achieve a chrome-like menu

qt,qml,qt-quick,qtquickcontrols

What I did for now is the last option that I mentioned: fake menu in the window. It's drawing using the canvas which enables me to make it a little pointy arrow from the menu to the menu toggle button, as done also by firefox. The minus as I said...

Qt Creator doesn't display QML folder

qt,qml,qt-creator,qtquick2,qt-quick

You need to add them to your .pro file (if I'm not wrong it's enough to append them to DISTFILES).

DPI-independent constant size in QML

qt,qml,qt5,qtquick2,qt-quick

Well, I've just might've found a solution: Screen.pixelDensity. But feel free to suggest anything better.

Comparison of two approaches to rendering raw OpenGL into a QML UI in Qt

qt,opengl,qml,qt-quick

The issue with QQuickWindow::beforeRendering() or QQuickWindow::afterRendering() signals is that all OpenGL drawing done from their slots will be appropriately under or over the rendered Qt Quick scene. If this is good enough for you — ie. you only want to draw a custom OpenGL background or some kind of overlay...

File inside resource cannot find local file

c++,qt,qml,qt-quick,resource-file

The QML engine assumes that relative paths addressed in QML files stored in the Qt Resource System are resolved within that resource file. So if your QML file is in a resource and you want to access a file in the application directory path you should set the path from...

Is it possible to deploy a Qt Quick application without Qt Network on OS X?

qt,qt5,qt-quick,qtnetwork

No. Prove The following command line script generates a dependency list of Qt 5 modules on Linux: # Run in e.g. Qt/5.4/gcc_64/lib for f in libQt5*.so; do mod=$(basename "$f" .so | cut -c "7-"); echo "$mod"; ldd "$f" | grep "libQt5" | cut -f 1 -d">" | tr -dc "a-zA-Z0-9.[:space:]"...

Extending QML ApplicationWindow in C++

c++,qt,qml,qt-quick

It seems like the job for qmlRegisterType. And it is a bit hard to say if you miss something with your C++ part but registering the type should help. That is for exposing the type itself and should enable the derived QQuickWindow functionality (derived from ApplicationWindow actually). But for what...

QML engine not implicitly converting a bool-string QVarient to bool property

c++,qt,qml,qt-quick

As described in ECMAScript language specification, converting to boolean return false, if value is +0, -0, null, false, NaN, undefined, or the empty string. All other values, including any object or the string "false", converted to true. Also, in QML you can use Qt Labs Settings QML Type instead of...

QML Dialog with focused textField

dialog,focus,qml,textfield,qt-quick

You don't need the function as it is written. From the docs of Dialog for the function open(): Shows the dialog to the user. It is equivalent to setting visible to true. Given that (it's not the problem) it seems like the focus is continously contended between the dialog and...

How to bind buttons in Qt Quick to Python PyQt 5

python,qt,pyqt,qml,qt-quick

If you name the button, you can connect to its onClick signal, or to a custom signal that it emits in onClicked. Example: ApplicationWindow { title: qsTr("Test Invoke") width: 200 height: 100 Button { signal messageRequired objectName: "myButton" y : 70 text : "About" onClicked: messageRequired() } } Note the...

How to make QtQuick transparent Toolbar

qml,toolbar,qt-quick,qtquick2

Since QtQuick.Controls.Styles 1.3 and Qt 5.2 you can use ToolBarStyle, i.e. you can write something like this (obviously with whatever padding you prefer): toolBar:ToolBar { style: ToolBarStyle { padding { left: 0 right: 0 top: 0 bottom: 0 } background: Rectangle { color: "transparent" } } RowLayout { anchors.fill: parent...

Warning when connecting c++ signal to qml slot

c++,qt,qt4,qml,qt-quick

I have defined qml slot like this : You are wrong. It is not slot definion, it's connection itself (the adding of QML handler for signal value_changed of object controllerObject). That's why you code works. But in this line : connect(this, SIGNAL(value_changed(double)), (QObject*)ui->view->rootObject(), SLOT(onValue_changed(double))); You are trying to connect...

Measuring elapsed time in QML

qt,time,qml,qtquick2,qt-quick

As explained in the comments, QML Timer is not suitable for your specific needs since it is synchronized with the animation timer (further details here) and thus its resolution is dependent on animation timer as well. @qCring solution is for sure satisfying and I would prefer such an approach, if...

Qt Android 5.3 Application Size

android,qt,qt-quick

I think you are adding many Qt modules. You should include only the necessary ones. This is a quote from BogDan Vatra the man who ported Qt to Android : Qt files can go slightly over 40Mb/platform if you are going to use all of Qt modules. Of course your...

Diiference between setContextProperty and setProperty of object

c++,qt,qml,qtquick2,qt-quick

setProperty is a member of QObject and is used to set a value for a property of a QObject. While setContextProperty is a member of QQmlContext class and is used to set the value of a name property on a qml context. You can read in the Qt documentation about...

QML: Using a Canvas in a RadioButtonStyle

qt,qml,qt-quick

The problem seems to be your update() function; it already exists in QQuickItem. If you rename it to updateColor(), for example, your code will work. I'm not sure why this is the case, as your update() function is still called regardless of whether there is a name clash, so I...

QML: closing QQuickWindow closes my application

c++,qt,qml,qtquick2,qt-quick

You can use setQuitOnLastWindowClosed in QGuiApplication. The property indicates whether the application should quit when the last window is closed or not. The default value is true, you can change it to false. Your main can be like : int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); qApp->setQuitOnLastWindowClosed(false); QQmlApplicationEngine...

`Screen.pixelDensity` equals 0 in non-visual components

qt,properties,qml,qtquick2,qt-quick

As mentioned in the QML doc for Screen The Screen attached object is valid inside Item or Item derived types, after component completion. Inside these items it refers to the screen that the item is currently being displayed on. If the item is not displayed (that's what I understood from...

Qt 5.3.0: process crashes complaining about free() in QQmlImageProviderBase when closing QQuickView

qt,qt5,qt-quick

Ok, I posted the question on Qt bug tracker and here is the answer: the QQmlImageProviderBase-derived object must be allocated on the heap because the QQmlEngine takes the ownership of it when it is added to the view... If it is allocated on the stack the object is going to...

QML/Qt4 for desktop: any demos? [closed]

qt,qml,qt-quick

For Qt 4.8.6 Qt Quick examples and demos located at QML Examples and Demos QML .qmlproject files used for QML Viewer but you can use QDeclarativeView widget and load QML file on it as described here: Integrating QML Code with Existing Qt UI Code....

QML Window opacity doesn't work when fullscreen

qt,qml,qt-quick

This is the age-old bug of the Qt/Win combination - windows with an OpenGL context, can't be made transparent without employing trickery. The solution is to embed your QML application in a QQuickWidget and make that transparent and full-screen. There also exists another workaround (using the 'DWM' API, which is...

Shortcut Ctrl+Down in Action

qt,qml,qtquick2,qt-quick,qtquickcontrols

From the documentation of shortcut you read that: Shortcut bound to the action. The keysequence can be a string or a standard key. From the QKeySequence toString() method documentation you also read that: Return a string representation of the key sequence, based on format. For example, the value Qt::CTRL+Qt::Key_O results...

Multiple “when”-conditions for a State

qml,state,qt-quick

There is nothing wrong about having multiple conditions for a State in a when, the problem here is having blue_state, circle_state and blue_circle_state all evaluating to true at the same time. The documentation about the when property of a State says : If multiple states in a group have when...

Add qml object to QGraphicsScene

c++,qt,qml,qt-quick,qgraphicsscene

You can add a QML in a QDeclarativeView to your scene using addWidget: QDeclarativeView view; view.setSource( QUrl("qrc:view.qml")); view.setStyleSheet("background-color:transparent"); QGraphicsProxyWidget * item = myScene->addWidget((QWidget *)view); For QtQuick 2.0 you can embed QQuickView in a widget using createWindowContainer : QQuickView *view = new QQuickView(); ... QWidget *container = QWidget::createWindowContainer(view); container->setMinimumSize(...); container->setMaximumSize(...);...

ListView in subwindow triggers immediate close, or whilst scrolling

qt,debugging,qml,qt-quick

As noted by @BaCaRoZzo the changing of behaviour by modifying the delegate code seems to be an unrelated side-issue. The real cause is because it turns out you cannot create new root contexts (i.e. top-level windows) from QML. This was hinted at being resolved when Qt Quick Components were released,...

The structure of a mobile app with Qt Quick Controls

android,qt,qt-quick,qtquick2,qtquickcontrols

It really depends on your needs, I'd say for basic apps a simple TabView will suffice, for more complex dialog design you will probably need a StackView. Naturally, you can also nest one into the other. Lastly, with QML it is easy enough to implement your custom app navigation system...

Invert ListView without filling the ListView from the bottom

listview,qml,qt-quick

I've now solved it by setting the ListView's height-property to contentHeight. I originally wanted to avoid this solution due to possible layout issues (binding loops etc.), but it'll have to do for now.

Where to put Qt QML non-visual application components

qt,qml,qt-quick

I have similar issues. I did have a look at some of the sources of Qt and figured you can do this: pragma Singleton import QtQuick 2.0 QtObject { property FontLoader fontLatoBlackLoader: FontLoader { name: "fontLatoBlack" source: "qrc:/fonts/Lato-Black.ttf" } } In your say fonts.qml file and then in the application...