hello community
the main program QMainWindow of the Qt application i am dealing with is using the GUI created by Qt designer: all the installed widgets (buttons etc.) are operating correctly. so far so good.
From Qt main windows a menu bar QMenuBar is then istantiated, then the a Qmenu and the related Qaction, (uartTestsPanelAction) which gets 'connected' to the system by the following code
connect(uartTestsPanelAction, SIGNAL(triggered()),this,SLOT(uartTestsShowDialog()));
connect(uartTestsPanelAction, SIGNAL(triggered()),this,SLOT(uartTestsShowDialog()));
To copy to clipboard, switch view to plain text mode
On click of "Uart tests" menu entry, the uartTestsShowDialog() pops up and run. Unfortunately, no action is performed, even if the buttons in the dialog box are pushed ....
Some sample code below
<foo.cpp>
{
// UI open
ui.setupUi(this);
m_uartTests = new uartTests_ui();
debugMenu->setTitle("&Debug");
menuBar->addMenu(debugMenu);
uartTestsPanelAction
= new QAction ("&Uart Tests",
this);
debugMenu->addAction(uartTestsPanelAction);
setMenuBar(menuBar);
connect(uartTestsPanelAction,SIGNAL(triggered()),this,SLOT(uartTestsShowDialog()));
//my button by GUI
connect(ui.pushButtonFunTests,SIGNAL(clicked()),this,SLOT (FunTestsShowDialog()));
m_uartTests->initialize(this);
}
void foo::uartTestsShowDialog()
{
m_uartTests->show();
}
<foo.cpp>
foo::foo(QWidget *parent, Qt::WFlags flags) : QMainWindow (parent, flags)
{
// UI open
ui.setupUi(this);
m_uartTests = new uartTests_ui();
menuBar = new QMenuBar;
debugMenu = new QMenu;
debugMenu->setTitle("&Debug");
menuBar->addMenu(debugMenu);
uartTestsPanelAction = new QAction ("&Uart Tests",this);
debugMenu->addAction(uartTestsPanelAction);
setMenuBar(menuBar);
connect(uartTestsPanelAction,SIGNAL(triggered()),this,SLOT(uartTestsShowDialog()));
//my button by GUI
connect(ui.pushButtonFunTests,SIGNAL(clicked()),this,SLOT (FunTestsShowDialog()));
m_uartTests->initialize(this);
}
void foo::uartTestsShowDialog()
{
m_uartTests->show();
}
To copy to clipboard, switch view to plain text mode
now aforementioned the dialog
<uartTests_ui.cpp>
uartTests_ui
::uartTests_ui(QWidget *parent, Qt
::WFlags flags
) : QDialog(parent, flags
){
// UI open
ui.setupUi(this);
// the following is NOT executed, even if the connected buttons are pushed ;(
connect(ui.pushButtonSendUart,SIGNAL(clicked()),this,SLOT (doSendUart()));
connect(ui.pushButtonCleanRx,SIGNAL(clicked()),this,SLOT(clearRxUart()));
}
uartTests_ui::~uartTests_ui()
{
}
void uartTests_ui
::initialize(ecmqMfgClient
* client,
QString comUsed
) {
m_client = client;
msg.append(comUsed);
ui.labelComUsed->setText(msg);
}
void uartTests_ui::doSendUart()
{
m_client->doSendUart();
}
{
return ui.lineEditTxUart->text();
}
void uartTests_ui::
clearRxUart()
{
ui.labelRx->setText(msg);
}
void
uartTests_ui
::setRxLabel(QString msg
){
ui.labelRx->setText(msg);
}
<uartTests_ui.cpp>
uartTests_ui::uartTests_ui(QWidget *parent, Qt::WFlags flags) : QDialog(parent, flags)
{
// UI open
ui.setupUi(this);
// the following is NOT executed, even if the connected buttons are pushed ;(
connect(ui.pushButtonSendUart,SIGNAL(clicked()),this,SLOT (doSendUart()));
connect(ui.pushButtonCleanRx,SIGNAL(clicked()),this,SLOT(clearRxUart()));
}
uartTests_ui::~uartTests_ui()
{
}
void uartTests_ui::initialize(ecmqMfgClient* client, QString comUsed)
{
m_client = client;
QString msg="COM USED: ";
msg.append(comUsed);
ui.labelComUsed->setText(msg);
}
void uartTests_ui::doSendUart()
{
m_client->doSendUart();
}
QString uartTests_ui::getTxEdit()
{
return ui.lineEditTxUart->text();
}
void uartTests_ui::
clearRxUart()
{
QString msg="RX: ";
ui.labelRx->setText(msg);
}
void
uartTests_ui::setRxLabel(QString msg)
{
ui.labelRx->setText(msg);
}
To copy to clipboard, switch view to plain text mode
thanks to anybody who'll help
the bottom line: why the widgets in a dialog box generated by the main windows are not active
Bookmarks