Results 1 to 2 of 2

Thread: Problems after changing flags to a QWidget

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2015
    Posts
    17
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Problems after changing flags to a QWidget

    Hi guys.
    I have a QWidget as the child of another within my application. The task consists of putting the internal widget in full screen mode and being able to see it again in normal mode with the same button. This partly I have managed to do it in the following way:
    Qt Code:
    1. if(!isFullScreen())
    2. {
    3. setWindowFlags(windowFlags() | Qt::Window);
    4. showFullScreen();
    5. }
    6. else
    7. {
    8. setWindowFlags(windowFlags() & ~Qt::Window);
    9. showNormal();
    10. activateWindow();
    11. }
    To copy to clipboard, switch view to plain text mode 
    The problem arises when you return to see the widget in normal mode. Things that happen:

    • The mouse cursor stays with pointing hand cursor.
    • The button to change mode remains in hover state (the background color is changed when the mouse is over).
    • Passing the mouse through other widget controls does not change its appearance.



    I have to click on the widget to fix the behavior. It's as if the widget did not receive events of any kind or something like that. I tried calling setFocus () and it did not work. I have also tried to send an event by hand in the following way but it has not worked either:
    Qt Code:
    1. QMouseEvent my_event(QEvent::MouseButtonPress, QPointF (0, 0), Qt :: NoButton, 0, 0);
    2. QApplication::sendEvent(this, & my_event);
    To copy to clipboard, switch view to plain text mode 
    Any ideas?

    Thanks.

  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: Problems after changing flags to a QWidget

    I am actually surprised this works for you as well as it does, I would not expect it.
    The reason being that you have a parented widget (not only in the sense of hierarchy but also in the visual sense).
    I wonder what the windowing system is doing when your widget goes to full screen mode - does it detach it from its parent (visually) and out of a layout it is in?
    If so, how does it know where to return it to...?
    I wonder if what you are doing is a misuse of the full screen functionality in that sense.

    In your place I would not have implemented it like that probably.
    I would pop up a new full screen widget which would have been cloned from the parented one.
    Makes everything much simpler and cleaner IMHO.
    ==========================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.

Similar Threads

  1. Changing QPalette doesn't affect to its QWidget
    By Binary91 in forum Qt Programming
    Replies: 10
    Last Post: 8th December 2016, 16:25
  2. QMake Platform Flags Problems
    By DanKolle in forum Qt Programming
    Replies: 2
    Last Post: 9th December 2014, 12:20
  3. Replies: 2
    Last Post: 18th August 2011, 08:26
  4. Replies: 0
    Last Post: 22nd March 2010, 19:00
  5. Qt on S60: setting window flags to QWidget don't work?
    By TheJ in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 18th September 2009, 12:10

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.