okay, here is my problem,(why I want to use global)
I have connected my mainwindow and dialog (thanks you you)
like this :
connect(ui
->lineEdit,
SIGNAL(textChanged
(QString)), dialog,
SLOT(seText
(QString)));
connect(ui->lineEdit, SIGNAL(textChanged(QString)), dialog, SLOT(seText(QString)));
To copy to clipboard, switch view to plain text mode
this is my event :
void MainWindow
::keyPressEvent(QKeyEvent *event
) {
int i=event->key();
//char z=(char)i;
qDebug()<<q;
if(i>=48&&i<=57)
{
q+=s;
ui->lineEdit->setText(q);
//qDebug()<<q;
}
if(q.length()>20&&flag==0)
{
//ui->lineEdit->setText("test");
dialog =new Dialog();
flag=1;
dialog->show();
raise();
activateWindow();
connect(ui
->lineEdit,
SIGNAL(textChanged
(QString)), dialog,
SLOT(seText
(QString)));
}
void MainWindow::keyPressEvent(QKeyEvent *event)
{
int i=event->key();
//char z=(char)i;
qDebug()<<q;
if(i>=48&&i<=57)
{
QString s= QString::number(i-'0');
q+=s;
ui->lineEdit->setText(q);
//qDebug()<<q;
}
if(q.length()>20&&flag==0)
{
//ui->lineEdit->setText("test");
dialog =new Dialog();
flag=1;
dialog->show();
raise();
activateWindow();
connect(ui->lineEdit, SIGNAL(textChanged(QString)), dialog, SLOT(seText(QString)));
}
To copy to clipboard, switch view to plain text mode
now, the problem is, the text is not displayed as the window opens, I have to input one more number to display the whole string in the dialog.
(how to make it such that , as the window opens, I can see the already input text)
because, there is one situation where textchanged is not emitted and the window is open.
Added after 38 minutes:
okay here is the deal
it works with integers .
suppose I make I=54 in mainwindow and print I in another window , it shows 54.
but it doesn't work with QStrings.
when I acesss qstring q from dialog 'dialog' , it show "" ;
Bookmarks