Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 71437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:53:15+00:00 2026-05-10T19:53:15+00:00

I want to display an image within a scroll area. The view port of

  • 0

I want to display an image within a scroll area. The view port of the scroll area shall have a defined initial size. That means, if the image’s size is bigger than the initial size of the view port, scroll bars will be visible, otherwise not.

// create label for displaying an image QImage image( ":/test.png" ); QLabel *label = new QLabel( this ); label->setPixmap( image.toPixmap() );  // put label into scroll area QScollArea *area = new QScrollArea( this ); area->setWidget( label );  // set the initial size of the view port // NOTE: This is what I'd like to do, but this method does not exist area->setViewPortSize( QSize( 300, 300 ) ); 

It shall be possible to resize the whole application so that the view port will get another size than the initial one.

Unfortunately, I was not able to find out, how to set the size of the view port. Qt’s layout mechanism seems to set a default size for the view port, but up to now I was not able to change it.

Setting a new size with area->setMinimumSize( QSize( 300, 300 ) ); will actually set the demanded size, but then the scroll area looses the ability to get resized to a size smaller than 300×300.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T19:53:16+00:00Added an answer on May 10, 2026 at 7:53 pm

    I think that you are looking at the problem the wrong way. The QScrollArea is just a widget that you put in a frame or QMainWindow. The size of the widget is controlled by the layout of the widget that contains it.

    Take a look at this example from Trolltech: Image Viewer Example

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have emoticons in a css sprite image that I want to display within
I have an Image that is 1500x2048 I want this to display at its
I want to create a scroll view with a massive contentSize that will display
I have an image that I want to fade in once the page loads.
I want to display the images present in my database on the Scroll view.Also
I have some divs holidng images I want to display. They are within a
I have some images that I want to display with a watermark. Currently they
I have here this code. I want it to first display an image file
I have an image within a div and I want either the image to
I want to display image using base64 encoding in IE using GWT If it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.