Originally Posted by
prophet0
in window_A.h
include "window_b.h"
private slot:
void showWindow_B();
and pointer to window_b in private so
Window_B *myWindow_B;
in window_A.cpp
add
in your main funtion
connect(ui.startButton, SIGNAL(clicked()), this, SLOT(showWindow_B());
void Window_A::showWindow_B
{
myWindow_B.show();
{
works in my current project with 5 uis
hi this is what i did....
window_a.h
#ifndef WINDOW_A_H
#define WINDOW_A_H
#include "window_b.h"
#include <QMainWindow>
namespace Ui {
class window_a;
}
{
Q_OBJECT
public:
explicit window_a
(QWidget *parent
= 0);
~window_a();
private slots:
void on_pushButton_clicked();
private:
Ui::window_a *ui;
};
#endif // WINDOW_A_H
#ifndef WINDOW_A_H
#define WINDOW_A_H
#include "window_b.h"
#include <QMainWindow>
namespace Ui {
class window_a;
}
class window_a : public QMainWindow
{
Q_OBJECT
public:
explicit window_a(QWidget *parent = 0);
~window_a();
private slots:
void on_pushButton_clicked();
private:
Ui::window_a *ui;
};
#endif // WINDOW_A_H
To copy to clipboard, switch view to plain text mode
window_b.h
#ifndef WINDOW_B_H
#define WINDOW_B_H
#include <QMainWindow>
namespace Ui {
class window_b;
}
{
Q_OBJECT
public:
explicit window_b
(QWidget *parent
= 0);
~window_b();
private:
Ui::window_b *ui;
};
#endif // WINDOW_B_H
#ifndef WINDOW_B_H
#define WINDOW_B_H
#include <QMainWindow>
namespace Ui {
class window_b;
}
class window_b : public QMainWindow
{
Q_OBJECT
public:
explicit window_b(QWidget *parent = 0);
~window_b();
private:
Ui::window_b *ui;
};
#endif // WINDOW_B_H
To copy to clipboard, switch view to plain text mode
window_a.cpp
#include "window_a.h"
#include "ui_window_a.h"
#include "window_b.h"
window_a
::window_a(QWidget *parent
) : ui(new Ui::window_a)
{
ui->setupUi(this);
}
window_a::~window_a()
{
delete ui;
}
void window_a::on_pushButton_clicked()
{
window_b * mywindow_b;
mywindow_b->show();
}
#include "window_a.h"
#include "ui_window_a.h"
#include "window_b.h"
window_a::window_a(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::window_a)
{
ui->setupUi(this);
}
window_a::~window_a()
{
delete ui;
}
void window_a::on_pushButton_clicked()
{
window_b * mywindow_b;
mywindow_b->show();
}
To copy to clipboard, switch view to plain text mode
window_b.cpp
#include "window_b.h"
#include "ui_window_b.h"
window_b
::window_b(QWidget *parent
) : ui(new Ui::window_b)
{
ui->setupUi(this);
}
window_b::~window_b()
{
delete ui;
}
#include "window_b.h"
#include "ui_window_b.h"
window_b::window_b(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::window_b)
{
ui->setupUi(this);
}
window_b::~window_b()
{
delete ui;
}
To copy to clipboard, switch view to plain text mode
main.cpp
#include <QtGui/QApplication>
#include "window_a.h"
int main(int argc, char *argv[])
{
window_a w;
w.show();
return a.exec();
}
#include <QtGui/QApplication>
#include "window_a.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
window_a w;
w.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
here when i executed the program in qt, window_a displays and when i click on the button(i.e to display window_a), program hangs......nothing comes!!!
what is the mistake i made????
Bookmarks