November 27, 2010

franklovecchio franklovecch..
Lab Rat
1 posts

QLabel showFullScreen not working correctly

 

I have an image that I display, and I’m trying to resize to fullscreen dynamically. The problem is that showFullScreen doesn’t work by itself; I have to set a QSize (and this is definitely not the correct way). What am I doing wrong?

  1. QImage image("c://default.png");
  2.  
  3. QLabel* imageLabel = new QLabel(this);
  4. imageLabel->setPixmap(QPixmap::fromImage(image));
  5. imageLabel->setAlignment(Qt::AlignCenter);
  6. //resize to fullscreen dynamically by device?
  7. imageLabel->resize(QSize(350, 600));
  8. //doesn't work on it's own
  9. imageLabel->showFullScreen();

11 replies

November 27, 2010

blex blex
Lab Rat
191 posts

From the Qt doc:

  1. void QWidget::showFullScreen ()
  2.  
  3. Calling this function only affects windows.

  1. bool QWidget::isWindow () const
  2.  
  3. Returns true if the widget is an independent window, otherwise returns false.

Is your widget independent window?

 Signature 

————————————

Oleksiy Balabay

November 28, 2010

Tobias Hunger Tobias Hunger
Mad Scientist
3155 posts

showFullScreen will not break the layout: What is the size policy of your widget? What are is the maximum size of it?

December 4, 2010

Deleted Member # 14e8 Deleted Member # 14e8
Lab Rat
355 posts

franklovecchio wrote:
I have an image that I display, and I’m trying to resize to fullscreen dynamically. The problem is that showFullScreen doesn’t work by itself; I have to set a QSize (and this is definitely not the correct way). What am I doing wrong?

Sorry to be so abrupt: but if it works, why bother? Get the app out the door, and make money!

December 4, 2010

Denis Kormalev Denis Kormalev
Lab Rat
1654 posts

tamhanna, not everythin that works is correct. Author just trying to find correct way to do things.

December 4, 2010

Deleted Member # 14e8 Deleted Member # 14e8
Lab Rat
355 posts

Not trying to offend.

Just trying to tell him to move on. You cannot always find perfect solution!

December 4, 2010

Deleted Member # 4a2 Deleted Member # 4a2
Ant Farmer
1481 posts
Tobias Hunger wrote:
showFullScreen will not break the layout: What is the size policy of your widget? What are is the maximum size of it?

yes check if you set any fixed size policy
also set the windowtype and windowflags to make it a top level window, then you should be able to show it full screen
also note the platform limitations as mentioned in the docs

December 4, 2010

Deleted Member # 4a2 Deleted Member # 4a2
Ant Farmer
1481 posts

tamhanna wrote:
Not trying to offend.

Just trying to tell him to move on. You cannot always find perfect solution!

the author knows that showing full screen by using size is flawed and is seeking a better solution. we are engineers and lets find a better way to do it. lets not forget quality.

also request you to post an answer only if you know the answer. else some other user who knows the answer, or who can provide good hints will pitch in. we are all here to learn and help each other.

thanks!

December 5, 2010

xsacha xsacha
Lab Rat
517 posts

chetankjain, ignore tamhanna – he’s just spamming and if you reply you give him a reason to reply again with ‘yes’ or ‘i agree’ or some other meaningless message.

The platform isn’t mentioned which could affect how showFullScreen works. The size of 350×600 seems suspicious for fullscreen. Not a desktop?

Also, is there any main window code? Or is this widget the window?

 Signature 

- Sacha

December 5, 2010

Deleted Member # 4a2 Deleted Member # 4a2
Ant Farmer
1481 posts

here goes:

  1. label->setWindowFlags(Qt::Window);
  2. label->setScaledContents(true);
  3. label->showFullScreen();

no hardcoding

December 5, 2010

xsacha xsacha
Lab Rat
517 posts

Remember that changing it to a Qt::Window will move it to the origin (0,0) relative to parent windows/desktop. It’s just using setParent().

Shouldn’t affect fullscreening. But maybe if you get out of fullscreen after.

You could use a maximise hint with a frameless border as an alternative to fullscreen as well.

http://doc.trolltech.com/latest/widgets-windowflags.html

 Signature 

- Sacha

December 6, 2010

franklovecchio franklovecch..
Lab Rat
1 posts

I set the parent Widget to showFullscreen and did a sizeHint on the imageLabel. It was the parent’s fault. (It’s not a desktop, but rather a mobile app)

 
  ‹‹ QDesktop openUrl problem in symbian      Error: PKG file does not exist, ’sis’ and ’installer_sis’ target are only supported for executables or projects with DEPLOYMENT statement ››

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