hi
i want to show multiple pushbuttons in the form dynamically!!! that is the number of pushbuttons i am showing ,will vary at runtime
.So i want to connect each button with signal and slot.i have created a function(i.e slot)
which will be called when any of the button is clicked..
for(int i=0;i<count;i++)
{
labelbed->setObjectName(bednumbersunderroom.at(i));
connect(labelbed,SIGNAL(clicked()),signalMapper,SLOT(map()));
signalMapper
->setMapping
(labelbed,labelbed
);
connect(signalMapper,
SIGNAL(mapped
(QWidget*)),
this,
SLOT(onbedclicked
(QWidget*)));
}
void Widget
::onbedclicked(QWidget* label
) {
msg->setText(label->objectName());
msg->show();
}
for(int i=0;i<count;i++)
{
QPushButton *labelbed =new QPushButton(roomgroup);
labelbed->setObjectName(bednumbersunderroom.at(i));
connect(labelbed,SIGNAL(clicked()),signalMapper,SLOT(map()));
signalMapper->setMapping(labelbed,labelbed); connect(signalMapper,SIGNAL(mapped(QWidget*)),this,SLOT(onbedclicked(QWidget*)));
}
void Widget::onbedclicked(QWidget* label)
{
QMessageBox *msg=new QMessageBox(this);
msg->setText(label->objectName());
msg->show();
}
To copy to clipboard, switch view to plain text mode
when any push button is clicked it displays message box but it displays as many messageboxes as push buttons...
for eg:if there are 3 push buttons,then if i click any one push button it displays 3 messagebox.But it should show only one messagebox..so how to do the signal slots
so that it will show one messagebox for each click!!!
thanks and regards
any help is highly appreciated


Bookmarks