简体   繁体   中英

Working with two user interfaces - Qt 5.5

I have a simple MainWindow which has a button and an LineEdit . When I type something and click a button, a new Dialog appears with a label that is supposed to display the string I typed. So basically, I have trouble sending information to another UI. I tried working with the new class with a string variable, but it didn't work.

I will try to give an example of what I want to do.

//ui2 Dialog
    ui2->label->setText(ui->LineEdit->text());

Ui is a an private variable, so it's not accessible from another class.

//mainwindow.cpp
MainWindow::MainWindow(QWidget*){
   this->_dialog = new Dialog(this);
   //...
}
MainWindow::on_pushButton_clicked(){
   _dialog->_labe->setText(ui->lineEdit->text());
}

//dialog.h
class Dialog{
public:
  QLabel* _label;
  Dialog(QWidget* ){
    _label = ui->label;
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM