Event happens when it shouldn't
-
Hi,
It is my first post here and I hope it gonna make you laugh.!
Well, this is not that easy to explain. In my code, there is a simple connection with a QPushButton which is supposed to shut down the program.
connect(quit, SIGNAL(clicked()), qApp, SLOT(quit()));
For a test (cause another button doesnt work), I removed this line BUT it is still working. So basically there is not SLOT on this button but for the program there is.
Obviously, I compiled again and again, clean, qmake, quit Qtcreator and tried again and again... AND it is still here.
Do you have any idea what could it be.?
Thanks in advance.
-
Hi, Welcome to DevNet.
Do you add QPushButton with QtDesigner or manualy in code? -
I did it manually
here is the cpp concerned :
#include "Win.h"
#include "Result.h"Win::Win()
{// /////////////////////////////////////////////////////////////////// //SETTLEMENT OF THE MAIN WINDOW // /////////////////////////////////////////////////////////////////// box11 = new QSpinBox(); box11->setSuffix(" mm"); box12 = new QSpinBox(); box12->setSuffix(" mm"); box13 = new QSpinBox(); box13->setSuffix(" mm"); box14 = new QSpinBox(); box14->setSuffix(" mm"); box15 = new QSpinBox(); box15->setSuffix(" mm"); box16 = new QSpinBox(); box16->setSuffix(" mm"); box17 = new QSpinBox(); box17->setSuffix(" mm"); box18 = new QSpinBox(); box18->setSuffix(" mm"); box21 = new QSpinBox(); box21->setSuffix(" mm"); box22 = new QSpinBox(); box22->setSuffix(" mm"); box23 = new QSpinBox(); box23->setSuffix(" mm"); box24 = new QSpinBox(); box24->setSuffix(" mm"); box25 = new QSpinBox(); box25->setSuffix(" mm"); box26 = new QSpinBox(); box26->setSuffix(" mm"); box27 = new QSpinBox(); box27->setSuffix(" mm"); box28 = new QSpinBox(); box28->setSuffix(" mm"); //initialisation of requirement spinboxes 1 and 2 boxE2 = new QSpinBox(); boxE2->setPrefix("E2> "); boxE2->setRange(0, 400); boxE2->setValue(100); boxE2E1 = new QDoubleSpinBox(); boxE2E1->setPrefix("E2/E1< "); boxE2E1->setRange(0, 10); boxE2E1->setValue(2.5); //initialisation of pushbutton b_quit = new QPushButton("quit"); calc = new QPushButton("calculate"); // /////////////////////////////////////// //spinboxes 1 layout // /////////////////////////////////////// layout1 = new QFormLayout; layout1->addRow("0 kPa", box11); layout1->addRow("50 kPa", box12); layout1->addRow("100 kPa", box13); layout1->addRow("200 kPa", box14); layout1->addRow("300 kPa", box15); layout1->addRow("100 kPa", box16); layout1->addRow("50 kPa", box17); layout1->addRow("0 kPa", box18); //spinboxes 2 layout layout2 = new QFormLayout; layout2->addRow("0 kPa", box21); layout2->addRow("50 kPa", box22); layout2->addRow("100 kPa", box23); layout2->addRow("200 kPa", box24); layout2->addRow("300 kPa", box25); layout2->addRow("100 kPa", box26); layout2->addRow("50 kPa", box27); layout2->addRow("0 kPa", box28); biglayout1 = new QHBoxLayout; biglayout1->addLayout(layout1); biglayout1->addLayout(layout2); groupmeasures = new QGroupBox("Measurements"); groupmeasures->setLayout(biglayout1); //requirement spinboxes 1 and 2 layout layout3 = new QHBoxLayout; layout3->addWidget(boxE2); layout3->addWidget(boxE2E1); grouprequirement = new QGroupBox("Requirement"); grouprequirement->setLayout(layout3); //pushbutton layout layout4 = new QHBoxLayout; layout4->addWidget(calc); layout4->addWidget(b_quit); layoutgrid = new QGridLayout; layoutgrid->addWidget(groupmeasures,0,0,1,2); layoutgrid->addWidget(grouprequirement,1,0,1,2); layoutgrid->addLayout(layout4,2,0,1,2); // /////////////////////////////////////////////////////////////////// // MAIN WINDOW SETTLED // /////////////////////////////////////////////////////////////////// // pushbuttons connection connect(calc, SIGNAL(clicked()), qApp, SLOT(quit()));
}
void Win::ouvrirDialogue()
{
// Vous insérerez ici le code d'ouverture des boîtes de dialogue
QMessageBox::information(this, "Titre de la fenêtre", "Bonjour et bienvenueà tous les Zéros !");}
-
Well, i dont know how to post the code...!
-
@#include "Win.h"
#include "Result.h"Win::Win()
{// /////////////////////////////////////////////////////////////////// //SETTLEMENT OF THE MAIN WINDOW // /////////////////////////////////////////////////////////////////// box11 = new QSpinBox(); box11->setSuffix(" mm"); box12 = new QSpinBox(); box12->setSuffix(" mm"); box13 = new QSpinBox(); box13->setSuffix(" mm"); box14 = new QSpinBox(); box14->setSuffix(" mm"); box15 = new QSpinBox(); box15->setSuffix(" mm"); box16 = new QSpinBox(); box16->setSuffix(" mm"); box17 = new QSpinBox(); box17->setSuffix(" mm"); box18 = new QSpinBox(); box18->setSuffix(" mm"); box21 = new QSpinBox(); box21->setSuffix(" mm"); box22 = new QSpinBox(); box22->setSuffix(" mm"); box23 = new QSpinBox(); box23->setSuffix(" mm"); box24 = new QSpinBox(); box24->setSuffix(" mm"); box25 = new QSpinBox(); box25->setSuffix(" mm"); box26 = new QSpinBox(); box26->setSuffix(" mm"); box27 = new QSpinBox(); box27->setSuffix(" mm"); box28 = new QSpinBox(); box28->setSuffix(" mm"); //initialisation of requirement spinboxes 1 and 2 boxE2 = new QSpinBox(); boxE2->setPrefix("E2> "); boxE2->setRange(0, 400); boxE2->setValue(100); boxE2E1 = new QDoubleSpinBox(); boxE2E1->setPrefix("E2/E1< "); boxE2E1->setRange(0, 10); boxE2E1->setValue(2.5); //initialisation of pushbutton b_quit = new QPushButton("quit"); calc = new QPushButton("calculate"); // /////////////////////////////////////// //spinboxes 1 layout // /////////////////////////////////////// layout1 = new QFormLayout; layout1->addRow("0 kPa", box11); layout1->addRow("50 kPa", box12); layout1->addRow("100 kPa", box13); layout1->addRow("200 kPa", box14); layout1->addRow("300 kPa", box15); layout1->addRow("100 kPa", box16); layout1->addRow("50 kPa", box17); layout1->addRow("0 kPa", box18); //spinboxes 2 layout layout2 = new QFormLayout; layout2->addRow("0 kPa", box21); layout2->addRow("50 kPa", box22); layout2->addRow("100 kPa", box23); layout2->addRow("200 kPa", box24); layout2->addRow("300 kPa", box25); layout2->addRow("100 kPa", box26); layout2->addRow("50 kPa", box27); layout2->addRow("0 kPa", box28); biglayout1 = new QHBoxLayout; biglayout1->addLayout(layout1); biglayout1->addLayout(layout2); groupmeasures = new QGroupBox("Measurements"); groupmeasures->setLayout(biglayout1); //requirement spinboxes 1 and 2 layout layout3 = new QHBoxLayout; layout3->addWidget(boxE2); layout3->addWidget(boxE2E1); grouprequirement = new QGroupBox("Requirement"); grouprequirement->setLayout(layout3); //pushbutton layout layout4 = new QHBoxLayout; layout4->addWidget(calc); layout4->addWidget(b_quit); layoutgrid = new QGridLayout; layoutgrid->addWidget(groupmeasures,0,0,1,2); layoutgrid->addWidget(grouprequirement,1,0,1,2); layoutgrid->addLayout(layout4,2,0,1,2); // /////////////////////////////////////////////////////////////////// // MAIN WINDOW SETTLED // /////////////////////////////////////////////////////////////////// // pushbuttons connection connect(calc, SIGNAL(clicked()), qApp, SLOT(quit()));
}
void Win::ouvrirDialogue()
{
// Vous insérerez ici le code d'ouverture des boîtes de dialogue
QMessageBox::information(this, "Titre de la fenêtre", "Bonjour et bienvenueà tous les Zéros !");}
@ -
And if you click on b_quit app closes?
-
yeah exactly. Whereas there is no connection anymore.
Moreover, I just checked if the compilation is good. There is problem...!It looks like my program corresponds to my former code. Weird tho
-
Anybody has an idea.?
-
Only thing that comes to mind, if clean - >qmake didn't help then try delete all build files manually and qmake - >Rebuild All.