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. showNormal, activateWindow, raise does not work
Qt 6.11 is out! See what's new in the release blog

showNormal, activateWindow, raise does not work

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 2.8k Views 3 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.
  • A Offline
    A Offline
    asd777
    wrote on last edited by
    #1

    I tried to run showNormal, activateWindow, raise but this command does not work.

    How can I change the size of a window from minimized to normal? I mean I has minimized window and I want to see this window in normal way. But how?

    This is video of my program (you can see that I run my program in minimized form and I wan not able to run this program in normal way) link text

    mainwindow.h

    mainwindow.h
    
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    
    #include <QWidget>
    
    #include <QTimer>
    
    namespace Ui {
    class MainWindow;
    }
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit MainWindow(QWidget *parent = 0);
        ~MainWindow();
        QTimer *timer;
    
    public slots:
        void MyTimerSlots();
    
    
    private:
        Ui::MainWindow *ui;
    };
    
    #endif // MAINWINDOW_H
    

    mainwindow.cpp

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    
    
    #include <QDebug>
    
    #include <QStyle>
    #include <QDesktopWidget>
    
    #include <QTime>
    #include <QDate>
    
    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
        QRect r1(QApplication::desktop()->screenGeometry(this).center().x()-300,
               QApplication::desktop()->screenGeometry(this).center().y()-300, 100, 200);
    
        setGeometry(r1);
        srand(std::time(0));
        showMinimized();
    
        QTimer *timer = new QTimer(this);
        connect(timer, SIGNAL(timeout()), this, SLOT(MyTimerSlots()) );
        timer->start(5000);
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    
     void MainWindow::MyTimerSlots()
    {
        qDebug() << "Timer..."<<QTime::currentTime().minute();
    
        //MainWindow::showFullScreen();
    
        showNormal();
        MainWindow::activateWindow();
        MainWindow::raise();
    
        //MainWindow::activateWindow();
    
    }
    
    raven-worxR 1 Reply Last reply
    0
    • A asd777

      I tried to run showNormal, activateWindow, raise but this command does not work.

      How can I change the size of a window from minimized to normal? I mean I has minimized window and I want to see this window in normal way. But how?

      This is video of my program (you can see that I run my program in minimized form and I wan not able to run this program in normal way) link text

      mainwindow.h

      mainwindow.h
      
      #ifndef MAINWINDOW_H
      #define MAINWINDOW_H
      
      #include <QMainWindow>
      
      #include <QWidget>
      
      #include <QTimer>
      
      namespace Ui {
      class MainWindow;
      }
      
      class MainWindow : public QMainWindow
      {
          Q_OBJECT
      
      public:
          explicit MainWindow(QWidget *parent = 0);
          ~MainWindow();
          QTimer *timer;
      
      public slots:
          void MyTimerSlots();
      
      
      private:
          Ui::MainWindow *ui;
      };
      
      #endif // MAINWINDOW_H
      

      mainwindow.cpp

      #include "mainwindow.h"
      #include "ui_mainwindow.h"
      
      
      #include <QDebug>
      
      #include <QStyle>
      #include <QDesktopWidget>
      
      #include <QTime>
      #include <QDate>
      
      MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
      {
          ui->setupUi(this);
          QRect r1(QApplication::desktop()->screenGeometry(this).center().x()-300,
                 QApplication::desktop()->screenGeometry(this).center().y()-300, 100, 200);
      
          setGeometry(r1);
          srand(std::time(0));
          showMinimized();
      
          QTimer *timer = new QTimer(this);
          connect(timer, SIGNAL(timeout()), this, SLOT(MyTimerSlots()) );
          timer->start(5000);
      }
      
      MainWindow::~MainWindow()
      {
          delete ui;
      }
      
       void MainWindow::MyTimerSlots()
      {
          qDebug() << "Timer..."<<QTime::currentTime().minute();
      
          //MainWindow::showFullScreen();
      
          showNormal();
          MainWindow::activateWindow();
          MainWindow::raise();
      
          //MainWindow::activateWindow();
      
      }
      
      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by raven-worx
      #2

      @asd777
      untested:

      if( w->windowState() & Qt::WindowMinimized )
          w->setWindowState( Qt::WindowNoState );
      w->activateWindow();
      

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • A Offline
        A Offline
        asd777
        wrote on last edited by
        #3

        This code does not work if I add this code to the function MyTimerSlots: (windows remain minimized)

        void MainWindow::MyTimerSlots()
        {
            qDebug() << "Timer..."<<QTime::currentTime().minute();
        
            //showNormal();
            //raise();
            //activateWindow();
        
            if( MainWindow::windowState() & Qt::WindowMinimized )
                MainWindow::setWindowState( Qt::WindowNoState );
            MainWindow::activateWindow();
        
        }
        
        raven-worxR 1 Reply Last reply
        0
        • A asd777

          This code does not work if I add this code to the function MyTimerSlots: (windows remain minimized)

          void MainWindow::MyTimerSlots()
          {
              qDebug() << "Timer..."<<QTime::currentTime().minute();
          
              //showNormal();
              //raise();
              //activateWindow();
          
              if( MainWindow::windowState() & Qt::WindowMinimized )
                  MainWindow::setWindowState( Qt::WindowNoState );
              MainWindow::activateWindow();
          
          }
          
          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @asd777
          on what OS are you running on?
          Maybe the window system doesn't allow it

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          1
          • A Offline
            A Offline
            asd777
            wrote on last edited by
            #5

            I use Ubuntu 16.04. Ubuntu is one of the most popular Linux distro.

            mrjjM 1 Reply Last reply
            0
            • A asd777

              I use Ubuntu 16.04. Ubuntu is one of the most popular Linux distro.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #6

              @asd777
              If possible, test on something beside Unity Desktop.
              KDE or XFCE to see if it works there.

              Update:
              Tried in Linux Mint 18.1 and it did work.
              The windows popped after 5 secs.

              1 Reply Last reply
              2

              • Login

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