Advertisement
oquidave

call on Qt widget from another

Aug 20th, 2012
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. #include "bioinfo.h"
  2. #include "ui_bioinfo.h"
  3. #include "biodisplay.h"
  4. #include <iostream>
  5.  
  6. using namespace std;
  7.  
  8. BioInfo::BioInfo(QWidget *parent) :
  9.     QMainWindow(parent),
  10.     ui(new Ui::BioInfo)
  11. {
  12.     ui->setupUi(this);
  13. }
  14.  
  15. BioInfo::~BioInfo()
  16. {
  17.     delete ui;
  18. }
  19.  
  20. void BioInfo::on_buttonBox_clicked(QAbstractButton *button)
  21. {
  22.     string name = ui->nameLineEdit->text().toStdString();
  23.     string age = ui->ageLineEdit->text().toStdString();
  24.  
  25.     cout << "your name is:  " << name << endl;
  26.     cout << "your age is:  " << age << endl;
  27.  
  28.     //call on the bioDisplay widget to show user's name and age
  29.     bioDisplay *dialog = new bioDisplay();
  30.    /*
  31.     the Qlabel object name that will diplay the name is called nameLabel and the
  32.     one that will display age is called ageLabel
  33.     i've tried ageLabel->setText(age) and nameLabel->setText(name), but my ide says
  34.     error: ‘ageDisplay’ was not declared in this scope
  35.  
  36.     */
  37.     dialog->setWindowTitle("Dialog");
  38.     ageDisplay->text();
  39.     dialog->show();
  40.  
  41.  
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement