I assume that you call this once to show window:
void MainWindow::cmdOutputDialog()
{
CmdOutputDialog *dlg=new CmdOutputDialog(this);
dlg->display(txtoutput);
dlg->exec();
}
void MainWindow::cmdOutputDialog()
{
CmdOutputDialog *dlg=new CmdOutputDialog(this);
dlg->display(txtoutput);
dlg->exec();
}
To copy to clipboard, switch view to plain text mode
and you want the text to be constantly updated. To achieve this, you need to perform explicit update of the displayed text, the fact that you do:
txtoutput.append(cmdoutput);
txtoutput.append(cmdoutput);
To copy to clipboard, switch view to plain text mode
not implies that string in 'dlg' will be updated, as this:
dlg->display(txtoutput);
dlg->display(txtoutput);
To copy to clipboard, switch view to plain text mode
assigns a copy of the original 'txtoutput' for display.
You need to update 'dlg' each time you receive new content:
QByteArray cmdoutput
= commandProcess.
readAllStandardOutput();
txtoutput.append(cmdoutput);
dlg->display(txtoutput);
QByteArray cmdoutput = commandProcess.readAllStandardOutput();
txtoutput.append(cmdoutput);
dlg->display(txtoutput);
To copy to clipboard, switch view to plain text mode
So, make CmdOutputDialog object a member of your MainWindow class, or define a signal in MainWindow and connect it to 'dlg' when you create it:
CmdOutputDialog *dlg=new CmdOutputDialog(this);
connect( this, SIGNAL(textUpdate(const QString&)), dlg, SLOT(display(const QString&)) );
dlg->display(txtoutput);
dlg->exec();
//... and then when text changes:
txtoutput.append(cmdoutput);
emit textUpdate(txtoutput);
CmdOutputDialog *dlg=new CmdOutputDialog(this);
connect( this, SIGNAL(textUpdate(const QString&)), dlg, SLOT(display(const QString&)) );
dlg->display(txtoutput);
dlg->exec();
//... and then when text changes:
txtoutput.append(cmdoutput);
emit textUpdate(txtoutput);
To copy to clipboard, switch view to plain text mode
Bookmarks