February 26, 2012

pascal95abc pascal95abc
Lab Rat
121 posts

How to dynamically create Rectangles ?

 

Hello.

I want to read information from a file in which is written in each line 4 points (x1,x2,y1,y2).

Now, I want to create a rectangle with this coordinates, but not in the design mode because the coordinates are not known before and they can always change.

Thank You.

 Signature 

Qt 4.7.3
Symbian OS v9.4 / Symbian^1, S60 5th Edition
on N97

2 replies

February 26, 2012

task_struct task_struct
Ant Farmer
353 posts

Hello,

QML can’t read files. You need to write a C++ plugin for that. Tutorial: Writing QML Extensions with C++ [doc.qt.nokia.com]

For example, you can write a model that provides coordinates and than use Repeater [doc.qt.nokia.com] to create rectangles.

Or you can create rectangle dynamicly from C++. It’s up to you.

 Signature 

“Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program.”
- Linus Torvalds

February 26, 2012

pascal95abc pascal95abc
Lab Rat
121 posts

Can I also load the file into a string(list) and then operating with the string / the stringlist ?

Then, I dont need to write an algorithm to open the file ?!

 Signature 

Qt 4.7.3
Symbian OS v9.4 / Symbian^1, S60 5th Edition
on N97

 
  ‹‹ OnKeyDown event (key down -> scroll down)      [SOLVED] Move a rectangle (set left,top) ››

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