hello, yea as deusinvictus said , use signal and slots, every time you type in the main window suppose in a text edit, catch the emitted signal in the dialog and create a slot in the dialog to do the work.
connect(txt,SIGNAL(textChanged()),myDialog,SLOT(setText(/*create this slot*/)));
QTextEdit *txt = new QTextEdit(this);
QDialog *myDialog = new QDialog(this);
connect(txt,SIGNAL(textChanged()),myDialog,SLOT(setText(/*create this slot*/)));
To copy to clipboard, switch view to plain text mode
if you dont want to use the textChanged SIGNAL , you can implement your Signal and emit it whenever you want holding the QString you need.
maybe emitting your own signal holding a QString as a parameter would be better and more convenient with the slot you want.
/*or*/connect(this,
SIGNAL(sendText
(QString/*implement it*/)),myDialog,
SLOT(setText
(QString/*create this slot*/)));
/*or*/connect(this,SIGNAL(sendText(QString/*implement it*/)),myDialog,SLOT(setText(QString/*create this slot*/)));
To copy to clipboard, switch view to plain text mode
where should I declare the variable so that both, Dialog.cpp & MainWindow.cpp can access it at the same time ?
just a note why do you need to access the same variable from different classes ie. making a variable accessible from 2 windows ?
Hope this helps.
Bookmarks