Randulf
30th May 2007, 09:00
Hi!!
I have an application where i can import raw videofiles and make some transformations on it.
When I am done I would want to open up a QDialog so that the user can specify some settings when exporting the sequence and when the user press the export button the sequence will be processed and exported. But I would want to keep it simple, i.e all this should be made in the same method with no connections like for example a QFileDialog.
I have made a new class that inherits from QDialog but I there must be some thing wrong.
When i call myDialog->exec() the dialog pops up but the code in the mainwindow contiues to execute.
I want the program to wait so that the user can make his choises in the dialog and when the ok button is pressed i can read out what settings was made and start export.
Kind of like this:
MyDialog myDialog = new MyDialog(this);
QStringList settings = myDialog->exec();
or
MyDialog myDialog = new MyDialog(this);
myDialog->exec();
QStringList settings = myDialog->getSettings();
When I use QFileDialog it possible to do like:
QString file = QFileDialog::getSaveFileName(.........
This is how I do it now:
void MainWindow::exportSequence()
{
// open a dialog for choosing export settings
MyDialog *md = new MyDialog(this);
md->exec();
qDebug() << esw->getSettings();
//start exporting video
.....
MyDialog:
class MyDialog: public QDialog
{
Q_OBJECT
public:
MyDialog(QWidget *parent=0);
QStringList getSettings() {return settings;}
public slots:
int exec();
void done(int val);
void accept();
void reject();
private:
QStringList settings;
QPushButton *exportButton;
QPushButton *cancelButton;
.....
Lots of buttons and other stuff
.....
};
MyDialog::MyDialog(QWidget *parent) : QDialog(parent)
{
setModal(true);
setFocusPolicy(Qt::StrongFocus);
setFocus();
......
exportButton = new QPushButton(tr("Export"));
connect(exportButton, SIGNAL(clicked()), this, SLOT(accept()));
cancelButton = new QPushButton(tr("Cancel"));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
.....
}
int MyDialog::exec()
{
activateWindow();
this->show();
return 1;
}
void MyDialog::done(int val)
{
printf("done()\n");
}
void MyDialog::accept()
{
settings << "setting1" << "setting2" << "ect";
printf("Accept.\n");
this->hide();
}
void ExportSequenceWidget::reject()
{
settings.clear();
printf("Reject.\n");
this->hide();
}
I have been looking at the examples but I can't really figure out how to do this.
Please help me solve this.
Many thanks.
//Nils
I have an application where i can import raw videofiles and make some transformations on it.
When I am done I would want to open up a QDialog so that the user can specify some settings when exporting the sequence and when the user press the export button the sequence will be processed and exported. But I would want to keep it simple, i.e all this should be made in the same method with no connections like for example a QFileDialog.
I have made a new class that inherits from QDialog but I there must be some thing wrong.
When i call myDialog->exec() the dialog pops up but the code in the mainwindow contiues to execute.
I want the program to wait so that the user can make his choises in the dialog and when the ok button is pressed i can read out what settings was made and start export.
Kind of like this:
MyDialog myDialog = new MyDialog(this);
QStringList settings = myDialog->exec();
or
MyDialog myDialog = new MyDialog(this);
myDialog->exec();
QStringList settings = myDialog->getSettings();
When I use QFileDialog it possible to do like:
QString file = QFileDialog::getSaveFileName(.........
This is how I do it now:
void MainWindow::exportSequence()
{
// open a dialog for choosing export settings
MyDialog *md = new MyDialog(this);
md->exec();
qDebug() << esw->getSettings();
//start exporting video
.....
MyDialog:
class MyDialog: public QDialog
{
Q_OBJECT
public:
MyDialog(QWidget *parent=0);
QStringList getSettings() {return settings;}
public slots:
int exec();
void done(int val);
void accept();
void reject();
private:
QStringList settings;
QPushButton *exportButton;
QPushButton *cancelButton;
.....
Lots of buttons and other stuff
.....
};
MyDialog::MyDialog(QWidget *parent) : QDialog(parent)
{
setModal(true);
setFocusPolicy(Qt::StrongFocus);
setFocus();
......
exportButton = new QPushButton(tr("Export"));
connect(exportButton, SIGNAL(clicked()), this, SLOT(accept()));
cancelButton = new QPushButton(tr("Cancel"));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
.....
}
int MyDialog::exec()
{
activateWindow();
this->show();
return 1;
}
void MyDialog::done(int val)
{
printf("done()\n");
}
void MyDialog::accept()
{
settings << "setting1" << "setting2" << "ect";
printf("Accept.\n");
this->hide();
}
void ExportSequenceWidget::reject()
{
settings.clear();
printf("Reject.\n");
this->hide();
}
I have been looking at the examples but I can't really figure out how to do this.
Please help me solve this.
Many thanks.
//Nils