Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.1k Topics 77.5k Posts
  • Are items out of listview visible area deleted ?

    2
    0 Votes
    2 Posts
    791 Views
    J
    Yes they are. Only as many items as you can see on screen are guaranteed to be alive at any given time, which is why you should be careful about relying on storing any state in the items themselves. You can set the cacheBuffer property to a higher value to keep more items alive in the view. This can sometimes improve scrolling performance at the cost of memory (and startup time).
  • 0 Votes
    2 Posts
    6k Views
    E
    https://bugreports.qt-project.org/browse/QTBUG-34100
  • How to use listview onAdd signal ?

    7
    0 Votes
    7 Posts
    6k Views
    W
    still not 'ad' output [quote author="Ever" date="1382423093"]Try to add x property to delegate so you can see better: @delegate: Rectangle { x: model.index * 50 Text { text:model.text } ListView.onAdd: { console.log("ad") } }@[/quote]
  • Create several dynamic objects

    4
    0 Votes
    4 Posts
    1k Views
    G
    Problem solved. My problem was the parent Item.
  • OpenGL calls with beforeRendering() and afterRendering() : sample code ?

    3
    0 Votes
    3 Posts
    2k Views
    F
    Just found exactly what I want here : http://qt-project.org/doc/qt-5.0/qtgui/openglwindow.html A QPainter with QOpenGLPaintDevice can paint on the OpenGL context in beforeRendering or afterRendering : @ if(!m_device) m_device = new QOpenGLPaintDevice; m_device->setSize(size()); QPainter painter(m_device); painter.setPen(Qt::blue); painter.drawText(QRect(0,0,width(),height()), Qt::TextDontClip, "Hello World"); @ However I still don't know why bare opengl instructions don't work as expected ! I'm actually exploring what the QOpenGLPaintDevice does using the glintercept tool.
  • [solved] text inside custom node in the scene graph

    5
    0 Votes
    5 Posts
    3k Views
    G
    Thank you very much, obviously I confused setParent and setParentItem. Now the code finally does what it is supposed to do. I still can not believe this really is the way you are supposed to do this, but it works, so I guess my problem is solved for now.
  • Calendar in Qt via QML(Solved)

    16
    0 Votes
    16 Posts
    9k Views
    D
    @ Item { id: dateGrid width: parent.width anchors.top: dayLabels.bottom anchors.topMargin: 5 anchors.bottom: parent.bottom property int currentActive: -1 GridLayout { columns: 7 width: parent.width height: parent.height columnSpacing: 10 rowSpacing: 10 Repeater { id: repeater model: firstDay + daysInMonth Rectangle { property bool highLighted: false property color normalColor Component.onCompleted: { if (index < firstDay) normalColor = calendar.color="green"; else { if(isToday(index-firstDay)) normalColor = "yellow"; else normalColor ="#eeeeee" } } color: dateMouse.pressed?"blue":(highLighted?"grey":normalColor) Layout.preferredWidth: (calendar.width - 20 - 60)/7 Layout.preferredHeight: (dateGrid.height - (dateLabels.rows - 1)*10)/dateLabels.rows Layout.fillWidth: true Layout.fillHeight: true Text { id: dateText color: highLighted?"yellow":"black" anchors.centerIn: parent text: index + 1 - firstDay opacity: (index < firstDay) ? 0 : 1 font.bold: isToday(index - firstDay) || highLighted } MouseArea { id: dateMouse enabled: index >= firstDay anchors.fill: parent onClicked: { var clickedDate = new Date( showDate.getFullYear(), showDate.getMonth() + 1, index + 1 - firstDay) console.log(Qt.formatDate(clickedDate, "dd/MM/yyyy")) if (dateGrid.currentActive != -1) { // unselect it repeater.itemAt(dateGrid.currentActive).highLighted = false; } if (!isToday(index - firstDay)){ highLighted = true dateGrid.currentActive = index } } } } } } } } }@
  • Qml scaling problem

    3
    0 Votes
    3 Posts
    1k Views
    K
    Hi mcosta, here is a javascript file with the logic: @var itemComponent = null; var draggedItem = null; var startingMouse; var posnInWindow; var posnObject; function startDrag(mouse) { posnInWindow = hallItem.mapToItem(hallEditor, 0, 0); startingMouse = { x: mouse.x, y: mouse.y } loadComponent(); } function addTable(object) { hallEditor.addTable(object) } function loadComponent() { if (itemComponent != null) { createItem(); return; } itemComponent = Qt.createComponent(hallItem.componentFile); if (itemComponent.status === Component.Loading) component.statusChanged.connect(createItem); else createItem(); } function createItem() { if (itemComponent.status === Component.Ready && draggedItem == null) { draggedItem = itemComponent.createObject(hallEditor, {"image": hallItem.image, "x": posnInWindow.x, "y": posnInWindow.y, "z": 1, "scale": hallscene.scale}); } else if (itemComponent.status === Component.Error) { draggedItem = null; console.log("error creating component"); console.log(itemComponent.errorString()); } } function continueDrag(mouse) { if (draggedItem == null) return; draggedItem.x = mouse.x + posnInWindow.x - startingMouse.x; draggedItem.y = mouse.y + posnInWindow.y - startingMouse.y; var itemPosY = window.doubleToInt((draggedItem.y - hallscene.y) / 20); var itemPosX = window.doubleToInt((draggedItem.x - hallscene.x) / 20); var Object = { x: itemPosX * 20, y: itemPosY * 20, width: draggedItem.width, height: draggedItem.height, numId: draggedItem.numId, rotation: draggedItem.rotation} hallEditor.isCollisionTest(draggedItem, Object) } function endDrag(mouse) { if (draggedItem == null) return; if (draggedItem.x < hallEditorFon.x || draggedItem.y < hallEditorFon.y || draggedItem.x + draggedItem.width > hallEditorFon.width || draggedItem.y + draggedItem.height > hallEditorFon.height || draggedItem.collision) { draggedItem.destroy(); draggedItem = null; } else { draggedItem.parent = hallscene draggedItem.scale = 1; draggedItem.numId = hallscene.numTable; hallscene.numTable++; var itemPosY = window.doubleToInt((draggedItem.y + -hallscene.y) / 20); var itemPosX = window.doubleToInt((draggedItem.x + -hallscene.x) / 20); draggedItem.y = itemPosY * 20; draggedItem.x = itemPosX * 20; draggedItem.created = true; // console.log("x", draggedItem.x, "y", draggedItem.y); hallEditor.push_back(draggedItem) draggedItem = null; } } @ I used these qml properties: @ scale: 1; transformOrigin: Item.TopLeft@ thanks in advance, Karen
  • Global position of Rectangle

    11
    0 Votes
    11 Posts
    5k Views
    H
    Yes. I'm also thinking of going for the ListView or some other form. However this will have the disadvantage that the list will not show outside the parent and that I have to fix the z-order issue when having multiple controlls... the latter should be manageable.
  • Nested menus using ListView

    4
    0 Votes
    4 Posts
    3k Views
    C
    So, is it possible to divide the sublists in seperate files? I tried a few different ways but without success. Any good advises? Example: FoodList.qml @ ListModel { id: foodList ListElement {name: "Fruits"; ??/subList: "fruitList"/ } ListElement {name: "Vegetables"; ??/subList: "vegtableList"/ } ListElement {name: "Meat"; ??/subList: "meatList"/ } }@ FruitList.qml @ ListModel { id: fruitList ListElement {name:"Apple} ListElement {name:"Banana} }@
  • QML: Get QObject parent

    2
    0 Votes
    2 Posts
    2k Views
    sierdzioS
    Very easy to do on the C++ side, just pass your item there and it's easily castable to QObject. Or try with parent.data, although your post would suggest it can return false data.
  • How to pass properties to a child window

    3
    0 Votes
    3 Posts
    1k Views
    G
    Look's like the forum lost a few posts. [quote author="p3c0" date="1382158485"]Hi, What if you don't assign the "Foo Bar" to userName ? Just keep it like this, @ property string userName@[/quote] If I do that that then it still passes through the initial value of userName, which in this case is "".
  • [SOLVED] QQmlListProperty viewing from QML

    6
    0 Votes
    6 Posts
    3k Views
    T
    Well your QVector still persists obviously, but the QList that is returned when calling toList() does not. Marked the thread as solved when you're done ;)
  • QtQuick OpenGL, render loop

    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • 0 Votes
    5 Posts
    3k Views
    B
    Ahhhhh, I got it. The whole time I had a error in reasoning. I missed that I was working with two different instances of the same class. I emitted the signals in the one instance and was waiting for the resulting signal from the other instance. Sure, that can not work.....
  • QML and extjs

    10
    0 Votes
    10 Posts
    5k Views
    L
    [quote author="Naouali" date="1302168306"]Is it possible to use extjs with QML ?[/quote] Yes is completely Possible. [quote author="Naouali" date="1302171303"]but since it uses javascript why it will never going to work ?[/quote] To do it work you need to recreate the ExtJS classes and call QML objects instead calling HTML elements in the views For example, in the documentation ("http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.button.Button" ) of extjs you can see that creating a button is as simple as: @Ext.create('Ext.Button', { text: 'Click me', renderTo: Ext.getBody(), handler: function() { alert('You clicked the button!'); } });@ But the problem is that QML by default dosn't renders ExtJS, so the posible solution is create a JS file into the QML project that mimics the ExtJS objects. @var component; var sprite; function create(name, arguments) { console.log('name:',name); component = Qt.createComponent(name +".qml"); sprite = component.createObject(appWindow, arguments); if (sprite == null) { // Error Handling console.log("Error creating object"); } } @ and them call this file from the main QML like this @import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Window 2.0 import 'content/Ext.js' as Ext Rectangle { id: appWindow width: 640 height: 480 Component.onCompleted: Ext.create('Button', {x: 200, y: 200, text:"hello2"}) } @ As you can see I can call Ext.create('Button') inside a QML Rectangle. Now the last step is to create the QML button file @ import QtQuick 2.0 Rectangle { id: container property variant text signal clicked height: text.height + 10; width: text.width + 20 border.width: 1 radius: 4 antialiasing: true gradient: Gradient { GradientStop { position: 0.0 color: !mouseArea.pressed ? "#eeeeee" : "#888888" } GradientStop { position: 1.0 color: !mouseArea.pressed ? "#888888" : "#333333" } } MouseArea { id: mouseArea anchors.fill: parent onClicked: container.clicked() } Text { id: text anchors.centerIn:parent font.pointSize: 10 text: parent.text } } @ this is the project directory example !http://lh5.googleusercontent.com/-6iNTA-KVA48/UmK_qUCsJHI/AAAAAAAAAA0/nsxK6UB9rDM/w240-h161-no/extjs_project.png(project_directory)!
  • [SOLVED] How to set a scrollbar to scroll down automatically?

    6
    0 Votes
    6 Posts
    21k Views
    M
    Yep, something like that, in fact, in the end, it was enough to split this line: @ QScrollArea * exprScroll = new QScrollArea();@ into @ QScrollArea * exprScroll;@ and @ exprScroll = new QScrollArea();@ The first one had to be put at the beginning of the code, so that expreScroll is declared as a global variable. Then the second one has to be put in another function that builds exprScroll, finally the rest of the above code can be in the function that adds widgets to the scroll area. I have a similar situation were I still have the same problem, but I guess it is a matter of nested functions to be carefully managed :) Thanks for your help.
  • Error in qjsvalue.h

    1
    0 Votes
    1 Posts
    647 Views
    No one has replied
  • Qml scaling problem

    Locked
    1
    0 Votes
    1 Posts
    567 Views
    No one has replied
  • Pass item into signal as an argument.

    3
    0 Votes
    3 Posts
    1k Views
    M
    Sierdzio, thanks a lot!!!