Hi,
I created 2 small examples with a QMainWindow that allows me to set the centralWidget using 4 widgets i created: graus000, graus090, graus180 and graus270.
I have 2 versions: v1 and v2.
v1 looks like this:
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow
::MainWindow(QWidget *parent
){
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_actionVer_a_0_graus_triggered()
{
frm000 = new graus000Form;
this->setCentralWidget(frm000);
}
void MainWindow::on_actionVer_a_90_graus_triggered()
{
frm090 = new graus090Form;
this->setCentralWidget(frm090);
}
void MainWindow::on_actionVer_a_180_graus_triggered()
{
frm180 = new graus180Form;
this->setCentralWidget(frm180);
}
void MainWindow::on_actionVer_a_270_graus_triggered()
{
frm270 = new graus270Form;
this->setCentralWidget(frm270);
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_actionVer_a_0_graus_triggered()
{
frm000 = new graus000Form;
this->setCentralWidget(frm000);
}
void MainWindow::on_actionVer_a_90_graus_triggered()
{
frm090 = new graus090Form;
this->setCentralWidget(frm090);
}
void MainWindow::on_actionVer_a_180_graus_triggered()
{
frm180 = new graus180Form;
this->setCentralWidget(frm180);
}
void MainWindow::on_actionVer_a_270_graus_triggered()
{
frm270 = new graus270Form;
this->setCentralWidget(frm270);
}
To copy to clipboard, switch view to plain text mode
This works but it seems i'm wasting memory here!?
v2 looks like this:
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow
::MainWindow(QWidget *parent
){
ui->setupUi(this);
frm000 = new graus000Form;
frm090 = new graus090Form;
frm180 = new graus180Form;
frm270 = new graus270Form;
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_actionVer_a_0_graus_triggered()
{
this->setCentralWidget(frm000);
}
void MainWindow::on_actionVer_a_90_graus_triggered()
{
this->setCentralWidget(frm090);
}
void MainWindow::on_actionVer_a_180_graus_triggered()
{
this->setCentralWidget(frm180);
}
void MainWindow::on_actionVer_a_270_graus_triggered()
{
this->setCentralWidget(frm270);
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
frm000 = new graus000Form;
frm090 = new graus090Form;
frm180 = new graus180Form;
frm270 = new graus270Form;
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_actionVer_a_0_graus_triggered()
{
this->setCentralWidget(frm000);
}
void MainWindow::on_actionVer_a_90_graus_triggered()
{
this->setCentralWidget(frm090);
}
void MainWindow::on_actionVer_a_180_graus_triggered()
{
this->setCentralWidget(frm180);
}
void MainWindow::on_actionVer_a_270_graus_triggered()
{
this->setCentralWidget(frm270);
}
To copy to clipboard, switch view to plain text mode
I set the centralWidget to graus000, then to othe value and then again to graus000 ... and it crashes.
Full examples here ( http://www.box.net/shared/ycvua1jarz ).
What's the best approach for doing what i'm trying to do here?
Thanks
Bookmarks