Results 1 to 20 of 20

Thread: inform QWidget that the screen dimensions changed

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2010
    Posts
    14
    Qt products
    Qt4 Qt/Embedded

    Default inform QWidget that the screen dimensions changed

    My platform changes orientation automatically while QWidget instance is running always full screen. When the rotation happens QWidget keeps old dimensions until it is switched forcefully to non-fullscreen mode and back to the full screen mode (where it finally occupies all screen space in new orientation).

    Anyone can suggest a way to refresh QWidget's dimensions while leaving it in full screen mode?

    Tried and failed to work: repaint(), setGeometry(), showFullscreen().

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: inform QWidget that the screen dimensions changed

    What happens if you try resize()?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Oct 2010
    Posts
    14
    Qt products
    Qt4 Qt/Embedded

    Default Re: inform QWidget that the screen dimensions changed

    I think I found the problem, it was an invisible parent widget sitting behind, when I refresh it then everything works ok.

  4. #4
    Join Date
    Oct 2010
    Posts
    14
    Qt products
    Qt4 Qt/Embedded

    Default Re: inform QWidget that the screen dimensions changed

    Hmm, still I have to get out of full screen mode and then get back in for Qt to pick up changes in screen dimensions. It works, but redrawing looks really ugly with a lot of flashing. Not sure what I can do about it.
    Ideas anyone?

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: inform QWidget that the screen dimensions changed

    Hard to say without seeing any code.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Oct 2010
    Posts
    14
    Qt products
    Qt4 Qt/Embedded

    Default Re: inform QWidget that the screen dimensions changed

    There is a repaint() and paintEvent() pair.The widget is created and running always full screen. When the widget needs an update it calls repaint(), then in paintEvent it regenerates its screen image and paints it using QPainter.

    The screen driver is based on QScreen. When the screen becomes landscape it starts reporting new height and width.

    So the widget needs to go into a non-fullscreen state (resize itself for example) and the back to fullscreen to see the new width/height of the screen.

    If the widget shows an image in portrait, then after changing the orientation of the device to landscape, the image is not shown completely until the resize/fullscreen is done.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: inform QWidget that the screen dimensions changed

    repaint and paintEvent are completely unrelated to the problem. They have nothing to do with dimensions of your window.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    Oct 2010
    Posts
    14
    Qt products
    Qt4 Qt/Embedded

    Default Re: inform QWidget that the screen dimensions changed

    OK. If the window receives showFullScreen() and it is in full screen it does nothing. It does not check that the screen has been changed. if it is sent resize(0,0) and then showFullScreen() then it occupies the full screen with new width and height.
    The code is trivial. Hardware changed in the background, but the changes are not propagated. Do I need to inform some Qt class that the sceen has been transformed? If yes then how?

    There are two methods in QScreen: isTransformed() and transformOrientation(). Both overwritten by my driver and return true/rotation corresponding the situation. No avail. I did a search through Qt and could see that those functions don't do much themselves, probably orientated on the transformation derived class functionality.

    @wysota: appreciate your answers, thanks.
    Last edited by Dzha; 4th November 2010 at 13:57.

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: inform QWidget that the screen dimensions changed

    Quote Originally Posted by Dzha View Post
    OK. If the window receives showFullScreen() and it is in full screen it does nothing. It does not check that the screen has been changed.
    The window does not check anything. It's your (or the window manager's) duty to know the screen size has changed.

    The code is trivial. Hardware changed in the background, but the changes are not proagated.
    Propagated where?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #10
    Join Date
    Oct 2010
    Posts
    14
    Qt products
    Qt4 Qt/Embedded

    Default Re: inform QWidget that the screen dimensions changed

    The window does not check anything. It's your (or the window manager's) duty to know the screen size has changed.
    OK. Is there a mechanism for informing the windows manager that the screen is changed?

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: inform QWidget that the screen dimensions changed

    You can start by reading what a window manager is.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. #12
    Join Date
    Oct 2010
    Posts
    14
    Qt products
    Qt4 Qt/Embedded

    Default Re: inform QWidget that the screen dimensions changed

    Well, all I was able to find while reading the window manager documentation was related to resizing the window, which I want to avoid.
    I can not see any method of not leaving the full screen mode (thus avoiding additional repaint) that is described in Qt doc.

    If you are aware of it, please tell me.

Similar Threads

  1. Finding a QWidget from a screen XY
    By andyp in forum Qt Programming
    Replies: 5
    Last Post: 26th August 2012, 09:15
  2. Replies: 12
    Last Post: 24th July 2010, 08:12
  3. Replies: 4
    Last Post: 8th August 2008, 17:28
  4. Display a QWidget using multi-screen
    By tarod in forum Qt Programming
    Replies: 3
    Last Post: 30th June 2008, 14:02
  5. Resizing screen dimensions using backbuffer in QT?
    By JimDaniel in forum Qt Programming
    Replies: 1
    Last Post: 24th September 2007, 23:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.