
Originally Posted by
Santosh Reddy
You may not have included the required ui file. See if this sample helps
#include "ui_OtherDialog.h"
void Dialog::on_pushButton_Clicked()
{
Ui::OtherDialog other_ui;
other_ui.setupUi(other_parent);
other_parent.exec();
}
#include "ui_OtherDialog.h"
void Dialog::on_pushButton_Clicked()
{
QDialog * other_parent = new QDialog(this);
Ui::OtherDialog other_ui;
other_ui.setupUi(other_parent);
other_parent.exec();
}
To copy to clipboard, switch view to plain text mode
Hmm... Just tried that, but now I'm getting an error whenever I access a member of ui (in the dialog class):
dialog.cpp:
#include "dialog.h"
#include "ui_dialog.h"
ui(new Ui::Dialog),
{
srand(time(0));
ui->setupUi(this);
ui->label->setVisible(false);
}
void Dialog::on_pushButton_clicked(){ //settings
Ui::settings foo;
foo.setupUi(parent);
parent->exec();
}
#include "dialog.h"
#include "ui_dialog.h"
Dialog::Dialog(QWidget *parent):
QDialog(parent),
ui(new Ui::Dialog),
{
srand(time(0));
ui->setupUi(this);
ui->label->setVisible(false);
}
void Dialog::on_pushButton_clicked(){ //settings
QDialog *parent = new QDialog(this);
Ui::settings foo;
foo.setupUi(parent);
parent->exec();
}
To copy to clipboard, switch view to plain text mode
dialog.h:
#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
#include <QtCore>
#include <QtGui>
#include "settings.h"
#include "ui_settings.h"
namespace Ui {
class Dialog;
class settings;
}
{
Q_OBJECT
public:
Ui::Dialog *ui;
explicit Dialog
(QWidget *parent
= 0);
~Dialog();
private slots:
void on_pushButton_clicked();
};
#endif // DIALOG_H
#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
#include <QtCore>
#include <QtGui>
#include "settings.h"
#include "ui_settings.h"
namespace Ui {
class Dialog;
class settings;
}
class Dialog : public QDialog
{
Q_OBJECT
public:
Ui::Dialog *ui;
explicit Dialog(QWidget *parent = 0);
~Dialog();
private slots:
void on_pushButton_clicked();
};
#endif // DIALOG_H
To copy to clipboard, switch view to plain text mode
Now, I get errors whenever I have "ui->" in my code.
Bookmarks