i confused on how whole thing works.
i have pushbuttons put group this:
mainwindow::mainwindow(qwidget *parent) : qmainwindow(parent), ui(new ui::mainwindow) { ui->setupui(this); addslotstogroup(); } void mainwindow::addslotstogroup() { qbuttongroup* group = new qbuttongroup(this); group->addbutton(ui->slot_0); group->addbutton(ui->slot_1); //... }
and want create slot gets id of button clicked in group. (sorry if explained poorly :( )
so did (pure guess after googling)
mainwindow::mainwindow(qwidget *parent) : qmainwindow(parent), ui(new ui::mainwindow) { ui->setupui(this); addslotstogroup(); connect(qpushbutton* group, signal(buttonclicked(int)), this, slot(ongroupbuttonclicked(int))); } void mainwindow::ongroupbuttonclicked(int id) { qdebug() << id; }
and no surprise, got error saying group undeclared identifier , qpushbutton illegal use etc.
i hate have used signals/slots designer window, need 1 thing, , i'm set future. :)
thanks time. :)
try following:
mainwindow::mainwindow(qwidget *parent) : qmainwindow(parent), ui(new ui::mainwindow) { ui->setupui(this); addslotstogroup(); } void mainwindow::addslotstogroup() { qbuttongroup* group = new qbuttongroup(this); group->addbutton(ui->slot_0); group->addbutton(ui->slot_1); //... connect(group, signal(buttonclicked(int)), this, slot(ongroupbuttonclicked(int))); }
by way, need learn c++ first master qt.
Comments
Post a Comment