Unsolved Display a Personal Object (Draw a Circle) on QScrollArea & QGridLayOut
-
hi
Ok, so now they show?
what u mean by focus is blocked? -
@mrjj That I can not scroll down the slider of QScrollArea.
The circles shown outside QScroll area, but not inside -
@yczo said:
grid->addWidget(circle[i],i,0);
but you add to grid?
That grid is in scrollarea?
How can it be outside?
The other objects u add, they are inside? -
@mrjj Yes, but don't shows. i think that the problem come from the way of generate the circle with absolute coordinates:
dc.drawEllipse(x,y,rad,rad);
x,y (absolute)
but i don't know another way, to make it.
Is There another method?Regards
-
@yczo
Hi it cant be absolute!
It will be relative to your self so the area
is 0,0, width, height !You draw inside. so u cannot ! use global x,y
you must move whole object! and it draws internal from 0,0so
dc.drawEllipse(x,y,rad,rad);
x,y can never be more than width / height :) -
@mrjj
We have a small misunderstanding, the new program draw twice, 15 circles out QScroll and should draw another 15 inside, but the last, don't make, just draw the first 15 created on mainwindowGreetings.
-
ok so it does draw and all is as you except ?
except the last is not inside the layout/scrollbox?Do u make these really big ?
new ampel(this,1333,768,5);is it 1333 x 768 ???
-
@mrjj 1333x768 is the size of layout where is permitted to draw
-
but if u must draw that big, it means u make the
Widget so big ?How big are the circle widgets?????
You can not draw outside the widget.
-
@mrjj Here is a hint: http://www.scriptscoop2.com/t/787129021050/qt-draw-inside-qscrollarea-in-a-qdialog.html
but i don't know how to:
Create another class which inherits QWidget. Override the paintEvent() method and to the painting you mention. Then, add the widget to the scroll area in your dialog. MyDialog::MyDialog() { QScrollArea *pScrl = new QScrollArea(this); pScrl->setWidget(new MyWidget(pScrl)); ... // use a layout to put the scroll area in the dialog } To really make it useful you will need to resize the MyWidget instance to the size of the circle that you want to draw.
Please can anybody help me? With a example?
Greetings