showNormal, activateWindow, raise does not work
Unsolved
General and Desktop
-
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(); }
-
@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(); }
-
@asd777
on what OS are you running on?
Maybe the window system doesn't allow it