PDA

View Full Version : Dialog box executed from main windows does not work ...



marco.stanzani
17th October 2011, 21:33
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( )));

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>

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()),t his,SLOT(uartTestsShowDialog()));

//my button by GUI
connect(ui.pushButtonFunTests,SIGNAL(clicked()),th is,SLOT (FunTestsShowDialog()));


m_uartTests->initialize(this);

}



void foo::uartTestsShowDialog()
{
m_uartTests->show();
}



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()),th is,SLOT (doSendUart()));
connect(ui.pushButtonCleanRx,SIGNAL(clicked()),thi s,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);
}



thanks to anybody who'll help
the bottom line: why the widgets in a dialog box generated by the main windows are not active