I wrote a simple QT calculator in VS2013. I used the signal released()
to call my slots, but my slot won't work. Maybe my signal never triggered. I'm new to QT, and I don't know what I did wrong.
My class has this property:
class Calculator : public QMainWindow
{
Q_OBJECT
public:
Calculator(QWidget *parent = 0);
~Calculator();
private slots:
void Calculator::two();
private:
QLabel *lable;
QPushButton *two_button;
QString value;
QString total;
int fnum;
int snum;
bool addbool;
bool subtractbool;
bool multiplybool;
bool devidebool;
};
This is my line of code for connecting the signal to the slot:
one_button = new QPushButton("2", this);
connect(two_button, SIGNAL(released()), this, SLOT(two()));
and my slot is
void Calculator::two()
{
value = value+"2";
lable->setText(value);
}
I put a breakpoint in my slot, but it never hit the breakpoint.
clicked()
instead ofreleased()
? – Mikevoid Calculator::two();
butvoid two();
– Haytone_button = new QPushButton("2",this);
butconnect(two_button,SIGNAL(re...
? – Sebastian Lange