Advertisement
oquidave

working with different Qt widgets

Sep 5th, 2012
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. //contactdialog.cpp
  2.  
  3. QLabel* ContactDialog::getNameLabel(){
  4.  
  5.     return ui->nameLabel;
  6. }
  7.  
  8. QLabel* ContactDialog::getAgeLabel(){
  9.  
  10.    return ui->ageLabel;
  11. }
  12.  
  13. //mainwindow.cpp
  14.  
  15. void MainWindow::on_buttonBox_accepted()//auto connected signal-slot
  16. {
  17.     ContactDialog *cd = new ContactDialog();
  18.     //get the labels from the contactdialog widget using it's accessor methods!!
  19. //then set the text user has entered from the mainwindow widget to it's labels!!
  20.     cd->getNameLabel()->setText(ui->agelineEdit->text());
  21.     cd->getAgeLabel()->setText(ui->namelineEdit->text());
  22.     cd->show();
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement