[Qt-interest] How to know which instance of QGraphicsView is the active view of a scene?
fog public
fogpub at gmail.com
Sun Jul 3 06:11:19 CEST 2011
Thanks for you hint, I have got a solution. Assuming not using CACHE mode
void MyGraphicsItem::paint(painter,option,widget)
{
if( widget != NULL )
{
QGraphicsView * pView = qtobject_cast<QGraphicsView* >
widget->parent();
.......
}
}
It is working nicely in my content,^_^
On Sun, Jul 3, 2011 at 12:02 PM, fog public <fogpub at gmail.com> wrote:
> Thanks for you hint, I have got a solution. Assuming not using CACHE mode
>
> void MyGraphicsItem::paint(painter,option,widget)
> {
> if( widget != NULL )
> {
> QGraphicsView * pView = qtobject_cast<QGraphicsView* >
> widget->parent();
> .......
> }
> }
> It is working nicely in my content,^_^
>
>
> On Thu, Jun 30, 2011 at 9:45 AM, <noam.rosenthal at nokia.com> wrote:
>
>>
>> On Jun 29, 2011, at 6:46 AM, ext fog public wrote:
>>
>> > Hi all,
>> > In Qt's document, I can get a QList of QGraphicsView* that display
>> the scene thought views(). but Which one is actived ? ( which view is
>> currently responsed for drawing the content of the scene.), thanks a lot.
>> > <ATT00001..txt>
>>
>> Assuming you have access to the item's paint function:
>>
>> void MyGraphicsItem::paint(painter, option, widget) {
>> QGraphicsView* whichView = 0;
>> for (int i = 0; i < scene()->views().size(); ++i)
>> if (scene->views()[i]->viewport() == widget)
>> whichView = scene->views()[i];
>> }
>>
>> There's probably a nicer way to code this, but this is the direction.
>> No'am
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110703/33ca5c38/attachment.html
More information about the Qt-interest-old
mailing list