December 13, 2011

rulovic rulovic
Lab Rat
5 posts

doubt getting window size

 

Hi all:
I’m creating an application using QMainWindow.
I’m using a label with a pixmap as a background, but I cannot get the complete window filled with the background image, probably due to the pixmap size. How I could achieve that?
At the same time I would like that if the window is resized background is still filling all the available window
Thanks in advance!!

3 replies

December 13, 2011

maxmotor maxmotor
Lab Rat
84 posts

I’m using a frame instead of a label.

  1. ui.frame->setGeometry(this->geometry());

Guess you could just scale the pixmap to the frame/label?

December 13, 2011

fluca1978 fluca1978
Ant Farmer
524 posts

This works for me:

  1.  QLabel* defaultCentralWidget = new QLabel( this );
  2.     defaultCentralWidget->setPixmap( QPixmap( ":/logo/img/logo/logo.png") );
  3.     defaultCentralWidget->setAlignment( Qt::AlignCenter );
  4.     defaultCentralWidget->setScaledContents( true );
  5.     setCentralWidget( defaultCentralWidget );

December 13, 2011

task_struct task_struct
Hobby Entomologist
344 posts

Hi,

take a look at this thread [developer.qt.nokia.com] and this one [developer.qt.nokia.com]

 Signature 

“Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program.”
- Linus Torvalds

 
  ‹‹ Tutorial for Qt designer      [SOLVED] QNetworkAccessManager get ››

You must log in to post a reply. Not a member yet? Register here!