for(unsigned j= 1; j<= 8; ++j)
{
// Adds the empty checkboxes
checkBox
->setGeometry
(QRect(50* (j
+ 1)+ 37,
20* i,
83,
20));
// We change the color of the check boxes to blue, using RGB.
//We make the Dialog object an event filter for all events of every check box.
checkBox->installEventFilter(this);
}
// Event handler for the check boxes' events
{
using namespace std;
if(event
->type
()== QEvent::MouseButtonRelease) {
QCheckBox *checkBox
= static_cast<QCheckBox
*>;
(target
);
return false;
}
else
return QDialog::eventFilter(target, event
);
}
for(unsigned j= 1; j<= 8; ++j)
{
// Adds the empty checkboxes
QCheckBox *checkBox= new QCheckBox(scrollAreaWidgetContents);
checkBox->setObjectName(QString("checkBox_%1%2").arg(QString::number(i)).arg(QString::number(j)));
checkBox->setGeometry(QRect(50* (j+ 1)+ 37, 20* i, 83, 20));
// We change the color of the check boxes to blue, using RGB.
checkBox->setPalette (QPalette(QColor(0, 0, 255)));
//We make the Dialog object an event filter for all events of every check box.
checkBox->installEventFilter(this);
}
// Event handler for the check boxes' events
bool Dialog::eventFilter(QObject *target, QEvent *event)
{
using namespace std;
if(event->type()== QEvent::MouseButtonRelease)
{
QCheckBox *checkBox= static_cast<QCheckBox *>;(target);
checkBox->setPalette(QPalette(QColor(255, 0, 0)));
return false;
}
else
return QDialog::eventFilter(target, event);
}
To copy to clipboard, switch view to plain text mode
Bookmarks