hi,
I wish to Display two Dialogs(one object initializes another object).
so i have created MM, SM classes.
MM is the main object.
i want to show SM, in MM's initialization.
so i declared the SM object in MM'S constructor.
But when running the program , Only the MM Dialog is Visible.
SM Dialog is not visible.
as per the functional flow, main() will create MM, and MM will show.
then MM will create SM. and SM has to show.
But im getting the err here.
pls let me know, where my code went wrong.
How to show the second dialog in first dialog's constructor?
Below are the complete code.
main.cpp
#include <QApplication>
#include "mm.h"
int main(int argc, char *argv[])
{
mm m;
return a.exec();
}
#include <QApplication>
#include "mm.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
mm m;
return a.exec();
}
To copy to clipboard, switch view to plain text mode
mm.h
#ifndef MM_H
#define MM_H
#include <QDialog>
#include <QtGui>
{
Q_OBJECT
public:
public slots:
void showMM();
};
#endif // MM_H
#ifndef MM_H
#define MM_H
#include <QDialog>
#include <QtGui>
class mm : public QDialog
{
Q_OBJECT
public:
mm(QWidget *parent = 0);
public slots:
void showMM();
};
#endif // MM_H
To copy to clipboard, switch view to plain text mode
mm.cpp
#include <QDialog>
#include <QLayout>
#include <QPushButton>
#include "mm.h"
#include "sm.h"
{
connect(p,SIGNAL(clicked()),this,SLOT(showMM()));
layout->addWidget(p);
setLayout(layout);
setWindowTitle("MainMenu");
show();
sm s;
}
void mm::showMM()
{
}
#include <QDialog>
#include <QLayout>
#include <QPushButton>
#include "mm.h"
#include "sm.h"
mm::mm(QWidget *parent)
: QDialog(parent)
{
QHBoxLayout *layout=new QHBoxLayout;
QPushButton *p = new QPushButton("MM");
connect(p,SIGNAL(clicked()),this,SLOT(showMM()));
layout->addWidget(p);
setLayout(layout);
setWindowTitle("MainMenu");
show();
sm s;
}
void mm::showMM()
{
QMessageBox::about(0,"","MM");
}
To copy to clipboard, switch view to plain text mode
sm.h
#ifndef SM_H
#define SM_H
#include <QDialog>
#include <QtGui>
{
Q_OBJECT
public:
public slots:
void showSM();
};
#endif // SM_H
#ifndef SM_H
#define SM_H
#include <QDialog>
#include <QtGui>
class sm : public QDialog
{
Q_OBJECT
public:
sm(QWidget *parent = 0);
public slots:
void showSM();
};
#endif // SM_H
To copy to clipboard, switch view to plain text mode
sm.cpp
#include "sm.h"
{
layout1->addWidget(p1);
setLayout(layout1);
setWindowTitle("sub");
this->show();
}
void sm::showSM()
{
}
#include "sm.h"
sm::sm(QWidget *parent)
: QDialog(parent)
{
QHBoxLayout *layout1=new QHBoxLayout;
QPushButton *p1 = new QPushButton("SM");
layout1->addWidget(p1);
setLayout(layout1);
setWindowTitle("sub");
this->show();
}
void sm::showSM()
{
QMessageBox::about(0,"","SM");
}
To copy to clipboard, switch view to plain text mode
thanks
Bala
Bookmarks