QMessageBox "ok" button closes whole program.
-
Hey guys i'm new to qt and I'm trying to display an error by opening up a new QMessage box when when a button is clicked and an input was wrong.
Here's by code
@void errorFunction()
{
if(/some code/)
{}
else
{
QMessageBox *msgBox== new QMessageBox();msgBox->setText("You didn't enter a number 1-5! Try again");
msgBox->exec();
}}@
-
Hi,
From where is errorFunction called ?
Note that you have a memory leak here. Either delete msgBox after the call to exec or allocate it on the stack.
-
Hi, errorFunction is called when I click a button. So I connected the button to this function like this:
@connect(rateButton,SIGNAL(clicked()),this,SLOT(errorFunction()));
@[quote author="SGaist" date="1417993095"]Hi,
From where is errorFunction called ?
Note that you have a memory leak here. Either delete msgBox after the call to exec or allocate it on the stack.[/quote]
-
What should be executed after that slot is called ?
-
And should that not be an assignment operator(=) instead of an equivalense test (==) operator