[Qt-interest] QScrollArea Help

yogesh upreti yogesh.upreti at gmail.com
Fri Apr 23 15:12:39 CEST 2010


Hallo All,
I tried this example but it dosen't solve my problem.
But with this I have narrowed down the problem to two steps.

I have created a QScrollArea(with resize policy Preferred) and in this a
QLable (with size policy Ignored) using QT-Creator.

Now the task is that in run time I load Image in QLable and I want to make
sure that when Image is smaller then QScrollArea than it should be displayed
in the center of the area, and when it is bigger ScrollArea should show
scroll bar so that user can scroll around the image. I have Scrollbar policy
as "Qt::ScrollBarAlwaysOn"

For this I QPixmap and assign it to QLable
Then I say QLable->adjustSize()

Problem
1. When I have QScrollArea -> widgetResizable(false) : The Image is not
displayed fully and I only see a cropped portion of image, and if this
cropped portion is bigger than QScrollArea then scrollbars are shown.
2. When I have QScrollArea -> widgetResizable(true) : The Image is shown
fully but it goes out of ScrollArea and scroll area doesn't show the Bars.

I amd using QT Creator to make this Window, so I don't know if there is any
proprty which should be set for QLable or QScrollArea so that I see full
Image and also the scrollbars when the image is big.

Have someone encountered the same problem anytime?
Or am I overlooking any property?

Please help

Thanks,
Yogesh Upreti
On Thu, Apr 22, 2010 at 5:38 PM, yogesh upreti <yogesh.upreti at gmail.com>wrote:

> I think I have the answer. see
> http://www.qtforum.org/article/17562/showing-image-in-qscrollarea-please-help.html?s=dd436d94a5da6244e4c7a0ef1610c4cf24cd0b65
> I haven't tried it yet, but its good information posted in net..
> I will try it and let reply in group about this
>
>
>
>
> On Thu, Apr 22, 2010 at 10:59 AM, Denis Akhmetzyanov <
> dakhmetzyanov at smartlabs.tv> wrote:
>
>> Hi,
>> Could you attach any code snippet? Is code from QScrollArea description
>> working well?
>>
>>  QLabel *imageLabel = new QLabel;
>>  QImage image("happyguy.png");
>>  imageLabel->setPixmap(QPixmap::fromImage(image));
>>
>>  scrollArea = new QScrollArea;
>>  scrollArea->setBackgroundRole(QPalette::Dark);
>>  scrollArea->setWidget(imageLabel);
>>
>> Is Image Viewer Example
>> http://doc.qt.nokia.com/4.6/widgets-imageviewer.html working well?
>>
>>
>> 2010/4/22 yogesh upreti <yogesh.upreti at gmail.com>
>>
>>>  Hallo Group,
>>> I am having some problem using QScrollArea
>>> I have a QLabel inside which displays image inside, but when the image
>>> size is big Scroll area is not showing scroll bars.
>>> I have Scroll Bar Policy for QScrollArea as Qt::ScrollBarAsNeeded
>>> but still it dose't show scroll bar for a bigger image.
>>>
>>> Can someone help me?
>>>
>>> Thanks
>>> Yogesh Upreti
>>>
>>>
>>> _______________________________________________
>>> Qt-interest mailing list
>>> Qt-interest at trolltech.com
>>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>>
>>>
>>
>>
>> --
>> Best regards,
>> Denis Akhmetzyanov
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100423/4de60474/attachment.html 


More information about the Qt-interest-old mailing list