Lol, it is something I can`t get rid. At university last year they taught/obliged us to do like this with simple methods:
void MyClass::MYMethodSetsAvalue (int value){
this->value = value;
}
void MyClass::MYMethodSetsAvalue (int value){
this->value = value;
}
To copy to clipboard, switch view to plain text mode
so from then on Its like riding a bike :P
BTW, any thoughts of my point 2) ?
Added after 9 minutes:
Chris,
I tried your approach of hiding the mainWindow. The thing is that, in that case I need to execute the Widgets in another window because every form/dialog is part of the central widget of the mainWindow. I mean I like it that way, I dont want my mom to think shes opening new windows with every click :P
Added after 36 minutes:
Before you waste your time: QstackedWidget is the holy blessed solution
As I will have only two widgets top in my stack, managing them is quite easy. I post the solution:
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
handler = -1;
ui->menuBar->setCornerWidget(corner);
stack_ventanas->addWidget (this->ui->centralWidget);
stack_ventanas->show ();
this->setCentralWidget (stack_ventanas);
}
void MainWindow
::accionFinalizada_Cancelada (QString url
){ //-----------IMAGEN CENTRAL---------
if (url.
contains (QString ("ya_cerramos"))) else{
RandomInfo *randurl = new RandomInfo ();
bg
= QPixmap (randurl
->getRandomUrl
());
}
this->ui->label_imagen->setPixmap (bg);
this->ui->label_author->hide ();
this->ui->label_text->hide ();
if (stack_ventanas->currentIndex () != 0){
stack_ventanas->removeWidget (stack_ventanas->widget (1));
stack_ventanas->setCurrentIndex (0);
}
this->ui->menuBar->show ();
}
void MainWindow::on_actionFacturacion_triggered()
{
this->ui->menuBar->hide ();
tipo_factura->exec ();
wfact = new widgetFacturacion(this, this->handler, tipo_factura->getTipoFactura ());
connect (wfact,
SIGNAL(widgetClosed
(QString )) ,
this,
SLOT(accionFinalizada_Cancelada
(QString)));
stack_ventanas->addWidget (wfact);
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
handler = -1;
ui->menuBar->setCornerWidget(corner);
stack_ventanas = new QStackedWidget;
stack_ventanas->addWidget (this->ui->centralWidget);
stack_ventanas->show ();
this->setCentralWidget (stack_ventanas);
}
void MainWindow::accionFinalizada_Cancelada (QString url){
//-----------IMAGEN CENTRAL---------
QPixmap bg;
if (url.contains (QString ("ya_cerramos")))
bg = QPixmap (url);
else{
RandomInfo *randurl = new RandomInfo ();
bg = QPixmap (randurl->getRandomUrl ());
}
this->ui->label_imagen->setPixmap (bg);
this->ui->label_author->hide ();
this->ui->label_text->hide ();
if (stack_ventanas->currentIndex () != 0){
stack_ventanas->removeWidget (stack_ventanas->widget (1));
stack_ventanas->setCurrentIndex (0);
}
this->ui->menuBar->show ();
}
void MainWindow::on_actionFacturacion_triggered()
{
this->ui->menuBar->hide ();
tipo_factura->exec ();
wfact = new widgetFacturacion(this, this->handler, tipo_factura->getTipoFactura ());
connect (wfact, SIGNAL(widgetClosed (QString )) ,this, SLOT(accionFinalizada_Cancelada(QString)));
stack_ventanas->addWidget (wfact);
}
To copy to clipboard, switch view to plain text mode
What you have to be careful is not to set any centralWidget of the mainWindow anymore.
BTW: you can correct any spell mistakes you see (and im talking specially of what I write here, not the code
), Im here to learn QT and English Lol :P
Thank you very much for the hint on Stacked widgets, my code is pretty neat now
Bookmarks