PDA

View Full Version : Add to KeyListWidget of another class



bismitapadhy
22nd March 2010, 08:16
I have one class1 abc - contains a QListWidget testscript
class2 test1 - Dialog - onOK() - add a string to the testscript QListwidget
class3 test2 - Dialog - onOK() - append a string to the testscript QListwidget

Everytime i can't create a object of the class1, because on creating object it will call the constructor and call the dialog.

Using the class name i am unable to add into QListWidget testscript. How can i do it give me any idea.

Lykurg
22nd March 2010, 08:46
How can i do it give me any idea.
Sorry, but I don't understand your question. Can you provide a minimal code example illustrating your problem.

bismitapadhy
22nd March 2010, 09:43
Sorry, but I don't understand your question. Can you provide a minimal code example illustrating your problem.
TestScriptGeneratorDialog::TestScriptGeneratorDial og(QWidget * parent): QDialog(parent)
{
setWindowTitle(tr("Test Script Generator"));
m_commandList = new QListWidget;
m_scriptList = new QListWidget;
}

void TestScriptGeneratorDialog::updateScriptList(QStrin g script)
{
m_scriptList->addItem(script); //List is not adding
}

PressKeyDialog::PressKeyDialog(QWidget * parent): QDialog(parent)
{
QPushButton *okButton = new QPushButton(tr("Ok"));
QPushButton *closeButton = new QPushButton(tr("Cancel"));

connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
connect(okButton, SIGNAL(clicked()), this, SLOT(onOk()));
}

void PressKeyDialog::onOk(void)
{

TestScriptGeneratorDialog *pTestScript = new TestScriptGeneratorDialog;
pTestScript->updateScriptList(capture);
}

The updateScriptList function get executed and the item is not added to the QListWidget. Please let me know what to do.

Lykurg
22nd March 2010, 10:48
Ok where do you call PressKeyDialog and TestScriptGeneratorDialog? are they related?

bismitapadhy
22nd March 2010, 10:57
Ok where do you call PressKeyDialog and TestScriptGeneratorDialog? are they related?

void TestScriptGeneratorDialog::onAdd()
{
int currentRow = m_commandList->currentRow();
PressKeyDialog *m_pressKey;
ReleaseKeyDialog *m_releaseKey;
CaptureDialog *m_capture;


switch(currentRow)
{
case 0:
break;
case 1:
m_pressKey = new PressKeyDialog(this);
if (m_pressKey)
{
m_pressKey->exec();
delete m_pressKey;
}
break;
}
}

I am calling presskeydialog from testscriptgeneratordialog.