MyWidget
::MyWidget(QWidget * parent
){
vLyt = new QVBoxlayout;
this->setLayout(vLyt);
addButtons(btn1, "background: green");
addButtons(btn2, "background: white");
addButtons(btn3, "background: black");
addButtons(btn4, "background: blue");
connect(btn1, SIGNAL(clicked(bool)), this, SLOT(mySlot1(bool))); // <<--- In debug mode, it's crashing here
connect(btn2, SIGNAL(clicked(bool)), this, SLOT(mySlot2(bool)));
connect(btn3, SIGNAL(clicked(bool)), this, SLOT(mySlot3(bool)));
connect(btn4, SIGNAL(clicked(bool)), this, SLOT(mySlot4(bool)));
}
{
pb->setCheckable(true);
pb->setStyleSheet(str);
vLyt->addWidget(pb);
}
MyWidget::MyWidget(QWidget * parent)
: QWidget(parent)
{
vLyt = new QVBoxlayout;
this->setLayout(vLyt);
addButtons(btn1, "background: green");
addButtons(btn2, "background: white");
addButtons(btn3, "background: black");
addButtons(btn4, "background: blue");
connect(btn1, SIGNAL(clicked(bool)), this, SLOT(mySlot1(bool))); // <<--- In debug mode, it's crashing here
connect(btn2, SIGNAL(clicked(bool)), this, SLOT(mySlot2(bool)));
connect(btn3, SIGNAL(clicked(bool)), this, SLOT(mySlot3(bool)));
connect(btn4, SIGNAL(clicked(bool)), this, SLOT(mySlot4(bool)));
}
void MyWidget::addButtons(QPushButton * pb, QString str)
{
pb = new QPushButton;
pb->setCheckable(true);
pb->setStyleSheet(str);
vLyt->addWidget(pb);
}
To copy to clipboard, switch view to plain text mode
Bookmarks