Hi all ! I'm having some troubles with connecting a comboBox and a function...
in .h
private slots:
/*! Call a quit function. */
void slotQuit();
/*! Call a function which can show an AboutForm. */
void slotAbout();
/*! Call a function which update the view when the comboBox is changed. */
void slotCurrentSelectionChanged();
private slots:
/*! Call a quit function. */
void slotQuit();
/*! Call a function which can show an AboutForm. */
void slotAbout();
/*! Call a function which update the view when the comboBox is changed. */
void slotCurrentSelectionChanged();
To copy to clipboard, switch view to plain text mode
in .cpp
{
// configuring the GUI
ui.setupUi(this);
// do connections
connect(ui.actionQuit, SIGNAL(activated()), this, SLOT(slotQuit()));
connect(ui.actionAbout, SIGNAL(activated()), this, SLOT(slotAbout()));
connect(ui.
comboBox,
SIGNAL(activated
(QString test
)),
this,
SLOT(slotCurrentSelectionChanged
()));
// end
}
// some code here...
void ui_murefImpl::slotCurrentSelectionChanged()
{
CLinkGUI::callCurrentSelectionChanged();
}
ui_murefImpl::ui_murefImpl(QWidget *parent) : QMainWindow(parent)
{
// configuring the GUI
ui.setupUi(this);
// do connections
connect(ui.actionQuit, SIGNAL(activated()), this, SLOT(slotQuit()));
connect(ui.actionAbout, SIGNAL(activated()), this, SLOT(slotAbout()));
connect(ui.comboBox, SIGNAL(activated(QString test)), this, SLOT(slotCurrentSelectionChanged()));
// end
}
// some code here...
void ui_murefImpl::slotCurrentSelectionChanged()
{
QMessageBox::information(0, "", "ok");
CLinkGUI::callCurrentSelectionChanged();
}
To copy to clipboard, switch view to plain text mode
By default I put 2 items in the comboBox... so that I can select them but I never saw the message box with ok...
(of course, the code compile fine... AND others slots function...)
Thanks a lot for the one who find out the solution .
edit: Oh, yeah, of course too, with the Designer I can add lower() function as a slot and it work perfectly...
QObject::connect(comboBox,
SIGNAL(activated
(QString)), MainWindow,
SLOT(lower
()));
QObject::connect(comboBox, SIGNAL(activated(QString)), MainWindow, SLOT(lower()));
To copy to clipboard, switch view to plain text mode
this line is added in ui_muref.h (generated from uic/moc tools)
Bookmarks