Waiting for User to Click Button, then continue code
-
So basically, I have a function
@
void mainInterface::simulation()
{//Initialize QTextCursor //Needed in every function that modifies the console! QTextEdit *editor = new QTextEdit(); editor = ui->console; QTextCursor cursor(editor->textCursor()); cursor.insertText(tr("\nDone!\n")); cursor.insertText(tr("Ready to begin simulation?")); ui->interactionButton2->setText("Begin"); ui->interactionButton3->setText("Back to Main Menu"); qApp->processEvents(); //Doesnt work.... I tried verifying by adding a qwait after it, and it just didnt update the GUI //Start printing a whole bunch more stuff to console.
}
@And I need it so that when interactionButton2 is pressed, it continues the program.
I have it connected to a slot here
@
connect(ui->interactionButton2, SIGNAL(pressed()), this, SLOT(button2Slot(int)));
@Here is my slot definition
@
void mainInterface::button2Slot(int casenumber2)
{
switch(casenumber2)
{
case 0:{
this->button2Response = true;
}
}
}
@If you need more details I'd be glad to give them, I've been frustrated by this program for so long I'll do anything haha. This may be something very simple to some of you vets, but Im just used to C#.
-
Hi,
Your connection is wrong,
A connection exists of:
connect(member, signal, member slot)A Signal may have more parameters than a slot, but not reverse..
you did:
@
connect(ui->interactionButton2, SIGNAL(pressed()), this, SLOT(button2Slot(int)));
@and you should remove the "int" argument of your slot, as it is not delivered by the signal.
some info:
http://qt-project.org/wiki/How_to_Use_QPushButton
http://qt-project.org/doc/qt-5.0/qtcore/signalsandslots.html -
Thanks for the reply Steven, I have been getting errors pertaining to my connections, but for the most part they have been functional.
When I tried your suggestion, it spit out in the Application Output
@
QObject::connect: No such slot mainInterface::button2Slot() in ..\DETSv0-1\maininterface.cpp:52
QObject::connect: (sender name: 'interactionButton2')
QObject::connect: (receiver name: 'mainInterface')
@But otherwise with how I had it I get,
@
QObject::connect: Incompatible sender/receiver arguments
QPushButton::pressed() --> mainInterface::button3Slot(int)
@Do you mean for me to absolutely not pass any variables to the slot at all? Remove int from the header and everything?
Besides that point, how about my most pertinent problem?
How to get the program to wait for the begin button to be pressed.