Results 1 to 12 of 12

Thread: Which event when raising a window

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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: Which event when raising a window

    What slot do you mean?
    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.


  2. #2
    Join Date
    Mar 2006
    Posts
    142
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Which event when raising a window

    According to your suggestion, I tried this:

    Qt Code:
    1. void
    2. myClass::changeEvent(QEvent *event)
    3. {
    4. if (event->type() == QEvent::ActivationChange) {
    5. if (this->windowState() & Qt::WindowActive) {
    6. printf("raised\n");
    7. }
    8. QWidget::changeEvent(event);
    9. }
    10. }
    To copy to clipboard, switch view to plain text mode 

    and I expected that clicking on the upper band of the window, making it the active window, would have made this slot executed.

  3. #3
    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: Which event when raising a window

    It's not a slot.

    And the docs say:

    QEvent::ActivationChange 99 A widget's top-level window activation state has changed.
    Again, it has nothing to do with the window being raised or not. Activation is related to the keyboard focus.
    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.


  4. #4
    Join Date
    Mar 2006
    Posts
    142
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Which event when raising a window

    You wrote:

    try checking for QEvent::ActivationChange instead
    so that is the reason I tried it!

  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: Which event when raising a window

    I have also written other things. Have you checked them?
    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
    Mar 2006
    Posts
    142
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Which event when raising a window

    Yes I understood that it is not possible to have all windows of an application raised together when one of them has been raised.
    I just investigated this route since you mentionned it.

  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: Which event when raising a window

    I meant the focusChanged() signal.
    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
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Which event when raising a window

    I don't know about chaning focus wysota mentioned, but changeEvent works perfectly fine on w7 an ubuntu for me:

    Qt Code:
    1. // main
    2. int main(int argc, char *argv[])
    3. {
    4. QApplication a(argc, argv);
    5. MainWindow w;
    6. w.show();
    7.  
    8. MainWindow w2;
    9. w2.show();
    10.  
    11. QObject::connect( &w, SIGNAL( activated( QWidget* ) ), &w2, SLOT( activate( QWidget* ) ) );
    12. QObject::connect( &w2, SIGNAL( activated( QWidget* ) ), &w, SLOT( activate( QWidget* ) ) );
    13.  
    14. return a.exec();
    15. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. // mainwindow.h
    2. #ifndef MAINWINDOW_H
    3. #define MAINWINDOW_H
    4.  
    5. #include <QtGui/QMainWindow>
    6.  
    7. class MainWindow : public QMainWindow
    8. {
    9. Q_OBJECT
    10.  
    11. public:
    12. MainWindow( QWidget* parent = 0 );
    13.  
    14. protected:
    15. void changeEvent( QEvent* e );
    16.  
    17. public slots:
    18. void activate( QWidget* w );
    19.  
    20. signals:
    21. void activated( QWidget* w );
    22. };
    23.  
    24. #endif // MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. // mainwindow.cpp
    2. #include "mainwindow.h"
    3.  
    4. #include <QEvent>
    5.  
    6. MainWindow::MainWindow( QWidget* p )
    7. :
    8. {
    9. }
    10.  
    11. void MainWindow::changeEvent( QEvent* e )
    12. {
    13. if( e->type() == QEvent::ActivationChange
    14. && this->isActiveWindow() )
    15. {
    16. emit this->activated( this );
    17. }
    18. QMainWindow::changeEvent( e );
    19. }
    20.  
    21. void MainWindow::activate( QWidget* w )
    22. {
    23. this->raise();
    24. this->stackUnder( w );
    25. }
    To copy to clipboard, switch view to plain text mode 

  9. #9
    Join Date
    Jan 2016
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Which event when raising a window

    Very good, thank you for this help,
    Ok with QT5 on Windows 8

Similar Threads

  1. Execute event in calling window
    By rdjenner in forum Qt Programming
    Replies: 2
    Last Post: 24th February 2011, 15:28
  2. Memory raising forever in server thread application
    By ruben.rodrigues in forum Newbie
    Replies: 4
    Last Post: 1st July 2010, 21:54
  3. Raising main Window above floating DockWidgets
    By skimpax in forum Qt Programming
    Replies: 2
    Last Post: 23rd December 2009, 09:03
  4. Raising the MainWindow to active/focused state
    By bmahf in forum Qt Programming
    Replies: 0
    Last Post: 5th November 2009, 21:15
  5. timerEvent is not raising
    By navi1084 in forum Qt Programming
    Replies: 2
    Last Post: 2nd September 2008, 22:07

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.