July 19, 2011

ucomesdag ucomesdag
Lab Rat
243 posts

Dynamically create qml objects

 

Hi, is it possible, for example, to create dynamically some rectangles?

Something like this:

  1. function drawButtons (buttons) {
  2.     for(var i=0; i<buttons; i++){
  3.         //=====================
  4.         Rectangle{
  5.             id: eval('item' + i)
  6.             y:  y_pos * i
  7.             width:  width
  8.             height: height
  9.             color: "red"
  10.         }
  11.         //=====================
  12.     }
  13. }

 Signature 

Write “Qt”, not “QT” (QuickTime).

2 replies

July 19, 2011

Lukas Geyer Lukas Geyer
Gene Splicer
2074 posts

Dynamic Object Management in QML [doc.qt.nokia.com].

July 19, 2011

ucomesdag ucomesdag
Lab Rat
243 posts

Exactly what I was looking for. Missed while searching.

Lukas Geyer wrote:
Dynamic Object Management in QML [doc.qt.nokia.com].

 Signature 

Write “Qt”, not “QT” (QuickTime).

 
  ‹‹ Memory leak or misunderstanding with QList<QObject*> as model      [SOLVED]adding width to a rectangle when mousearea is clicked ››

You must log in to post a reply. Not a member yet? Register here!