PDA

View Full Version : close application window



seltra
7th October 2010, 17:32
myproject::myproject(QWidget *parent, Qt::WFlags flags): QMainWindow(parent, flags)
{
ui.setupUi(this);
start();

}


how can i close widget window from the method??


void myproject::start()

{

ui.centralwidget.close()
}

mcosta
7th October 2010, 17:42
Hi,
what exactly you would to do?
You cannot close a widget contained by other widget. you can hide it

seltra
7th October 2010, 18:15
Hi,
what exactly you would to do?
You cannot close a widget contained by other widget. you can hide it

I print on screen "Press Q to quit program"
with keypressevent i check whether user presses Q_Key.


void myproject::keyPressEvent ( QKeyEvent * event )
{
if(event->key() == Qt::Key_Q)
{
ui->close();
}
}

seltra
7th October 2010, 18:58
i said false.
i'm trying to quit application, not the widget.

this code doesn't work..



void myproject::keyPressEvent ( QKeyEvent * event )
{
if(event->key() == Qt::Key_Q)
{
app.quit();
}
}

Lykurg
7th October 2010, 22:17
see qApp or QCoreApplication::instance().

seltra
8th October 2010, 19:12
see qApp or QCoreApplication::instance().

thank you lykurg.

qApp->quit();
solved my problem.