You are not logged in.

1

Friday, January 26th 2007, 8:14pm

Scaling a Pixmap

Hi dear all friends,

I am writing a board game which the board is a m*n table of marbles.
My problem is scaling the image of the marble to fit each cell's size(Each cell is a QLabel, and I use QPixmap to load the image and send it to the label).

Would you tell me how to do this? (better to say both in Qt3 and Qt4, but any one is also enough)

Thanks & Regards,
Pooria

This post has been edited 3 times, last edit by "j_pooria" (Jan 26th 2007, 8:46pm)


saubue

Trainee

Posts: 129

Location: Germany

  • Send private message

2

Sunday, January 28th 2007, 10:39pm

Hi j_pooria,

Have you tried QLabel::setScaledContents (Qt4)?

huzefar

Trainee

  • "huzefar" is male

Posts: 101

Location: London, UK

Occupation: software engineer

  • Send private message

3

Monday, January 29th 2007, 11:13am

this should help u out !!

QPixmap pix(:/"path of teh image");

QSize size = label->size();

QPixmap QPixmap::scaled ( size, Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio, Qt::TransformationMode transformMode = Qt::FastTransformation ) const


cheers
Regards
Huzy...

4

Wednesday, January 31st 2007, 12:19pm

Hi dear friends,
Both of them worked!
Thank you!