showNormal, activateWindow, raise does not work



  • 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();
    
    }
    

  • Moderators

    @asd777
    untested:

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


  • 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();
    
    }
    

  • Moderators

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



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


  • Qt Champions 2016

    @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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.