Reputation: 4136
In qdialog i put some input that i need in the mainwindow, how can i get them? my program is something like this, I have a qdialog that must open before mainwindow, I put there some input and click ok, and then the mainwinodw opens using those inputs.
here's the dialog.cpp code:
#include "dialog.h"
#include "ui_dialog.h"
#include "vtkBMPReader.h"
// Define the length of the volume
void Dialog::bmprange()
{
// Getting some proprieties for the lenght of the volume
QString XMAX=ui->lineEdit->text();
double xMax=XMAX.toDouble();
QString YMAX=ui->lineEdit_2->text();
double yMax=YMAX.toDouble();
QString ZMAX=ui->lineEdit_3->text();
double zMax=ZMAX.toDouble();
QString XMMAX=ui->lineEdit_4->text();
double xMMax=XMMAX.toDouble();
QString YMMAX=ui->lineEdit_5->text();
double yMMax=YMMAX.toDouble();
QString ZMMAX=ui->lineEdit_6->text();
double zMMax=ZMMAX.toDouble();
if (xMax==0 || yMax==0 || zMax==0 || xMMax==0 || yMMax==0 || zMMax==0)
{
ui->label_17->setText("Error: invalid measures");
}
else
{
// Using vtkBMPReader to read all the 128 bmp slices
vtkBMPReader *bmp= vtkBMPReader::New();
bmp->SetDataByteOrderToLittleEndian();
bmp->SetFilePrefix ("/home/matt/Desktop/ouBMP/exemplo");
bmp->SetFilePattern("%s%d.bmp");
bmp->SetFileNameSliceSpacing(1);
bmp->SetNumberOfScalarComponents(3);
bmp->SetDataOrigin(0,0,0);
bmp->SetDataSpacing(xMMax/(xMax-1.0),xMMax/(yMax-1.0),xMMax/(zMax-1.0));
bmp->SetDataExtent(0,xMax-1.0,0,yMax-1.0,1,zMax);
bmp->Update();
ui->label_17->setText("Valid measures");
}
}
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
// Control volume measures
// Making the lineedit objects only accept numbers
ui->lineEdit->setValidator(new QIntValidator(this));
ui->lineEdit_2->setValidator(new QIntValidator(this));
ui->lineEdit_3->setValidator(new QIntValidator(this));
ui->lineEdit_4->setValidator(new QDoubleValidator(this));
ui->lineEdit_5->setValidator(new QDoubleValidator(this));
ui->lineEdit_6->setValidator(new QDoubleValidator(this));
connect(ui->lineEdit, SIGNAL(textChanged(QString)), this, SLOT(bmprange()));
connect(ui->lineEdit_2, SIGNAL(textChanged(QString)), this, SLOT(bmprange()));
connect(ui->lineEdit_3, SIGNAL(textChanged(QString)), this, SLOT(bmprange()));
connect(ui->lineEdit_4, SIGNAL(textChanged(QString)), this, SLOT(bmprange()));
connect(ui->lineEdit_5, SIGNAL(textChanged(QString)), this, SLOT(bmprange()));
connect(ui->lineEdit_6, SIGNAL(textChanged(QString)), this, SLOT(bmprange()));
}
Dialog::~Dialog()
{
delete ui;
}
void Dialog::changeEvent(QEvent *e)
{
QDialog::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
how can i get bmp, xMax, ... to use in mainwindow
Upvotes: 0
Views: 1162
Reputation: 20359
I don't speak C++, so sorry for the lack of details. Here's what I'd do:
closeEvent
that you should have when you close your dialog. If your dialog has a OK
button, you can use its clicked
signal.QLineEdit
in a single object (a QStringList
, for example) and (2) to actually close your dialog.QStringList
as an attribute of your main window, or as an independent object you can retrieve from your main window.Upvotes: 1