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?

    @QImage image("c://default.png");

    QLabel* imageLabel = new QLabel(this);
    imageLabel->setPixmap(QPixmap::fromImage(image));
    imageLabel->setAlignment(Qt::AlignCenter);
    //resize to fullscreen dynamically by device?
    imageLabel->resize(QSize(350, 600));
    //doesn't work on it's own
    imageLabel->showFullScreen();@



  • From the Qt doc:

    @
    void QWidget::showFullScreen ()

    Calling this function only affects windows.
    @

    @
    bool QWidget::isWindow () const

    Returns true if the widget is an independent window, otherwise returns false.
    @

    Is your widget independent window?


  • Moderators

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



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



  • [quote author="Tobias Hunger" date="1290932386"]showFullScreen will not break the layout: What is the size policy of your widget? What are is the maximum size of it?
    [/quote]

    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



  • [quote author="tamhanna" date="1291465736"]Not trying to offend.

    Just trying to tell him to move on. You cannot always find perfect solution![/quote]

    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!



  • 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 350x600 seems suspicious for fullscreen. Not a desktop?

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



  • here goes:

    @
    label->setWindowFlags(Qt::Window);
    label->setScaledContents(true);
    label->showFullScreen();
    @

    no hardcoding



  • 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



  • 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)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.