/*First UI header*/
namespace Ui {
class RaptorLrsGUI;
}
{
Q_OBJECT
public:
explicit RaptorLrsGUI
(QWidget *parent
= 0);
~RaptorLrsGUI();
private:
Ui::RaptorLrsGUI *ui;
};
/*Second UI header */
namespace Ui {
class RaptorCoreGUI;
}
{
Q_OBJECT
public:
explicit RaptorCoreGUI
(QWidget *parent
= 0);
~RaptorCoreGUI();
void configInitData(bool);
private:
Ui::RaptorCoreGUI *ui;
};
/*Base class header*/
{
Q_OBJECT
public:
RaptorLrsGUI *lrsGUI;
RaptorCoreGUI *coreGUI;
~Base();
explicit Base
(QWidget *parent
= 0);
private slots:
void rcvInitData();
};
/* Second UI cpp */
RaptorCoreGUI
::RaptorCoreGUI(QWidget *parent
) : ui(new Ui::RaptorCoreGUI)
{
ui->setupUi(this);
this->setAutoFillBackground(true);
this->setStyleSheet("background-color:white;");
}
RaptorCoreGUI::~RaptorCoreGUI()
{
delete ui;
}
void RaptorCoreGUI
::setlabel(QString label
) {
qDebug() << "Main Thread(COREGUI): Setting Label\n";
ui->label->setText(label);
}
/*First ui cpp*/
RaptorLrsGUI
::RaptorLrsGUI(QWidget *parent
) : ui(new Ui::RaptorLrsGUI)
{
ui->setupUi(this);
this->setAutoFillBackground(true);
this->setStyleSheet("background-color:white;");
}
RaptorLrsGUI::~RaptorLrsGUI()
{
qDebug() << "Main Thread: destroying the ui object \n";
delete ui;
}
void RaptorLrsGUI
::setlabel(QString label
) {
qDebug() << "Main Thread(LSRGUI): Setting Label\n";
ui->label->setText(label);
}
/* Main.cpp */
{
qDebug() << "Base CTOR called\n";
//Show the first screen, loading raptor status
lrsGUI = new RaptorLrsGUI;
lrsGUI
->setlabel
(QString("Loading Raptor Status..."));
coreGUI = new RaptorCoreGUI;
//this->setCentralWidget(this->stackedWidget); // If uncommented it directly shows second UI
stackedWidget->addWidget(lrsGUI);
stackedWidget->addWidget(coreGUI);
stackedWidget->setCurrentIndex(0);
stackedWidget->showMaximized();
}
Base::~Base()
{
qDebug() << "Main Thread: destroying base objects \n";
delete lrsGUI;
delete coreGUI;
delete stackedWidget;
}
void Base::rcvInitData()
{
qDebug()<< "Main Thread (CALLBACK): Display second screen\n";
stackedWidget->setCurrentIndex(1);
}
//! [1]
int main(int argc, char *argv[])
{
//Instantiate base class
Base baseObj;
//instantiate Client thread object
ClientThread clientThread;
qDebug() << "Connecting sendmsg and handle_callback1()\n";
QObject::connect(&clientThread,
SIGNAL(sendInitData
()),
&baseObj,
SLOT(rcvInitData
()), Qt
::QueuedConnection);
qDebug() << "Main Thread: starting clockThread\n";
clientThread.start();
app.exec();
qDebug() << "Mian Thread: Quiting clockThread\n";
clientThread.quit();
qDebug() << "Main Thread: Waiting on clockThread \n";
clientThread.wait();
return 0;
}
/*First UI header*/
namespace Ui {
class RaptorLrsGUI;
}
class RaptorLrsGUI : public QMainWindow
{
Q_OBJECT
public:
explicit RaptorLrsGUI(QWidget *parent = 0);
~RaptorLrsGUI();
void setlabel(QString);
private:
Ui::RaptorLrsGUI *ui;
};
/*Second UI header */
namespace Ui {
class RaptorCoreGUI;
}
class RaptorCoreGUI : public QMainWindow
{
Q_OBJECT
public:
explicit RaptorCoreGUI(QWidget *parent = 0);
~RaptorCoreGUI();
void configInitData(bool);
void setlabel(QString);
private:
Ui::RaptorCoreGUI *ui;
};
/*Base class header*/
class Base : public QMainWindow
{
Q_OBJECT
public:
RaptorLrsGUI *lrsGUI;
RaptorCoreGUI *coreGUI;
QStackedWidget *stackedWidget;
QVBoxLayout *layout;
~Base();
explicit Base (QWidget *parent = 0);
private slots:
void rcvInitData();
};
/* Second UI cpp */
RaptorCoreGUI::RaptorCoreGUI(QWidget *parent) :
QMainWindow(parent, Qt::FramelessWindowHint),
ui(new Ui::RaptorCoreGUI)
{
ui->setupUi(this);
this->setAutoFillBackground(true);
this->setStyleSheet("background-color:white;");
}
RaptorCoreGUI::~RaptorCoreGUI()
{
delete ui;
}
void RaptorCoreGUI::setlabel(QString label)
{
qDebug() << "Main Thread(COREGUI): Setting Label\n";
ui->label->setText(label);
}
/*First ui cpp*/
RaptorLrsGUI::RaptorLrsGUI(QWidget *parent) :
QMainWindow(parent, Qt::FramelessWindowHint),
ui(new Ui::RaptorLrsGUI)
{
ui->setupUi(this);
this->setAutoFillBackground(true);
this->setStyleSheet("background-color:white;");
}
RaptorLrsGUI::~RaptorLrsGUI()
{
qDebug() << "Main Thread: destroying the ui object \n";
delete ui;
}
void RaptorLrsGUI::setlabel(QString label)
{
qDebug() << "Main Thread(LSRGUI): Setting Label\n";
ui->label->setText(label);
}
/* Main.cpp */
Base::Base(QWidget *parent) : QMainWindow(parent, Qt::FramelessWindowHint)
{
qDebug() << "Base CTOR called\n";
//Show the first screen, loading raptor status
lrsGUI = new RaptorLrsGUI;
lrsGUI->setlabel(QString("Loading Raptor Status..."));
coreGUI = new RaptorCoreGUI;
stackedWidget = new QStackedWidget();
//this->setCentralWidget(this->stackedWidget); // If uncommented it directly shows second UI
stackedWidget->addWidget(lrsGUI);
stackedWidget->addWidget(coreGUI);
stackedWidget->setCurrentIndex(0);
stackedWidget->showMaximized();
}
Base::~Base()
{
qDebug() << "Main Thread: destroying base objects \n";
delete lrsGUI;
delete coreGUI;
delete stackedWidget;
}
void Base::rcvInitData()
{
qDebug()<< "Main Thread (CALLBACK): Display second screen\n";
stackedWidget->setCurrentIndex(1);
}
//! [1]
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
//Instantiate base class
Base baseObj;
//instantiate Client thread object
ClientThread clientThread;
qDebug() << "Connecting sendmsg and handle_callback1()\n";
QObject::connect(&clientThread, SIGNAL(sendInitData()), &baseObj, SLOT(rcvInitData()), Qt::QueuedConnection);
qDebug() << "Main Thread: starting clockThread\n";
clientThread.start();
app.exec();
qDebug() << "Mian Thread: Quiting clockThread\n";
clientThread.quit();
qDebug() << "Main Thread: Waiting on clockThread \n";
clientThread.wait();
return 0;
}
To copy to clipboard, switch view to plain text mode
Bookmarks