Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Resolved] QWidget window flag behavior changed in Qt 4.8?
Forum Updated to NodeBB v4.3 + New Features

[Resolved] QWidget window flag behavior changed in Qt 4.8?

Scheduled Pinned Locked Moved General and Desktop
10 Posts 3 Posters 6.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    ronM71
    wrote on last edited by
    #1

    I have a certain QWidget derived class.

    Look at the window flags i'm giving it. In my app it functions like the drop down component of the combo box:

    @setWindowFlags(Qt::FramelessWindowHint | Qt::Popup);@

    with Qt 4.7.4, the "FocusOutEvent" is called when I click outside of the widget, even if the click is on the window caption. I use the event to hide my widget. That's the desired behavior I'd like to see. With Qt 4.8 however, "FocusOutEvent" is never called when clicking outside my widget on non-focus receiving elements and/or my window caption, thus, it still sticks around. I can actually drag the window away from my still-visible popup widget...

    Something changed in Qt 4.8 something changed. Is there a way around it?

    1 Reply Last reply
    0
    • R Offline
      R Offline
      ronM71
      wrote on last edited by
      #2

      None of the conventional techniques work here. No mouse grabbing, no eventFilter. Qt doesn't get any event when i click my OSX window caption. I show my popup, grab my OSX window caption, and drag the window away from the still opened popup. For me, this is a new deal-breaker bug introduced in Qt 4.8. Qt 4.7.4 works well, the popup disappears as soon as I click the window caption. Reluctantly I am forced to revert to 4.7.4. Pity.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        ronM71
        wrote on last edited by
        #3

        This really sucks as I have to revert to Qt 4.7.4, missing out on all the bug fixes of Qt 4.8

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lgeyer
          wrote on last edited by
          #4

          Have you already filed a bug report?

          1 Reply Last reply
          0
          • R Offline
            R Offline
            ronM71
            wrote on last edited by
            #5

            I intend to today.

            1 Reply Last reply
            0
            • R Offline
              R Offline
              ronM71
              wrote on last edited by
              #6

              Submitted:

              https://bugreports.qt-project.org/browse/QTBUG-24162

              1 Reply Last reply
              0
              • L Offline
                L Offline
                lgeyer
                wrote on last edited by
                #7

                Perfectly. Please add a link to this thread to the bug report.

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  ronM71
                  wrote on last edited by
                  #8

                  added.

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    goetz
                    wrote on last edited by
                    #9

                    I have a similar use case and I install an eventFilter on the QApplication object - that receives the mouse click. I then check if the click is on my object or any subwidgets of it. If not, I close that widget. That special popup is used with exec(), just like a menu or a dialog. I'll show the implementation of exec() and the eventFilter() here:

                    @
                    QChar MySpecialPopup::exec()
                    {
                    if( _eventLoop ) {
                    qWarning("MySpecialPopup::exec: Recursive call detected");
                    return QChar();
                    }

                    _selectedChar = QChar();
                    
                    bool deleteOnClose = testAttribute(Qt::WA_DeleteOnClose);
                    setAttribute(Qt::WA_DeleteOnClose, false);
                    
                    _dialogIsOpen = true;
                    show();
                    qApp->setActiveWindow( this );
                    setFocus();
                    qApp->installEventFilter( this );
                    installEventFilter(this);
                    
                    QEventLoop eventLoop;
                    _eventLoop = &eventLoop;
                    QPointer<MySpecialPopup> guard = this;
                    connect( qApp, SIGNAL(focusChanged(QWidget*,QWidget*)),
                             this, SLOT(focusChanged(QWidget*,QWidget*)));
                    
                    (void) eventLoop.exec&#40;QEventLoop::DialogExec&#41;;
                    
                    disconnect( qApp, SIGNAL(focusChanged(QWidget*,QWidget*)),
                                this, SLOT(focusChanged(QWidget*,QWidget*)));
                    
                    _dialogIsOpen = false;
                    removeEventFilter(this);
                    qApp->removeEventFilter( this );
                    hide();
                    
                    if (guard.isNull())
                        return QChar();
                    
                    _eventLoop = 0;
                    if (deleteOnClose)
                        delete this;
                    
                    return _selectedChar;
                    

                    }

                    bool MySpecialPopup::eventFilter(QObject *obj, QEvent *event)
                    {
                    if( !_dialogIsOpen )
                    return MyBaseClassWidget::eventFilter( obj, event );

                    if(event->type() == QEvent::MouseButtonPress
                       && obj != this 
                       && !findChildren<QObject *>().contains( obj )
                     ) {
                        exitEventLoop( QChar() );
                        return MyBaseClassWidget::eventFilter( obj, event );
                    }
                    

                    #if !defined(Q_WS_MAC)
                    } else if( event->type() == QEvent::WindowDeactivate ) {
                    exitEventLoop( QChar() );
                    return MyBaseClassWidget::eventFilter( obj, event );
                    #endif

                    #if !defined(Q_WS_X11)
                    } else if( event->type() == QEvent::ApplicationDeactivate ) {
                    exitEventLoop( QChar() );
                    return MyBaseClassWidget::eventFilter( obj, event );
                    #endif
                    }
                    return MyBaseClassWidget::eventFilter( obj, event );
                    }
                    @

                    http://www.catb.org/~esr/faqs/smart-questions.html

                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      ronM71
                      wrote on last edited by
                      #10

                      Volker, you are a mad scientist ;-)
                      I'll give that a try in the next couple of days.

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved