Drawing multiple rectangles in Qt
-
Hi,
How can I draw rectangles in a grid fasion?
What I want is to draw rectangle shapes, for instance 5 rectangles on the X and 10 on the Y axis with a spacing in between each rectangle forming a grid.
Thanks a lot
-
-
Using QGraphicsView and QGraphicsScene
-
Subclass QWidget, then override paintEvent()
-
-
Are you using C++ with widgets or QGraphicsView, or are you using QML?
-
I'm using c++ and Qt Creator?
Can someone be so kind and post a lttle sample?
Thanks
-
[quote author="fs_tigre" date="1334009290"]
Can someone be so kind and post a lttle sample?[/quote]In my opinion the "Basic Drawing Example":http://qt-project.org/doc/qt-4.8/painting-basicdrawing.html will be useful for you.
-
bq. In my opinion the Basic Drawing Example [qt-project.org] will be useful for you.
I have tried this before but I guess I haven't tried hard enough.
Thanks
-
[quote author="fs_tigre" date="1334010989"]bq. In my opinion the Basic Drawing Example [qt-project.org] will be useful for you.
I have tried this before but I guess I haven't tried hard enough.
Thanks[/quote]
Give it another shot :) It demonstrates how to draw different shapes, including a rectangles and how to customize their pen and brush style.
-
Took RenderArea class from basicdrawing and insert into my project. Not able to create a sequence of Triangle object
////////////////////////////////////////////////////////////////////////
RenderArea* renderArea;
//////////////////////////////////////////////////////////////
renderArea = new RenderArea;RenderArea::Shape shape = RenderArea::Shape(4);
renderArea->setShape(shape);Layout_page2->addWidget(renderArea);