PDA

View Full Version : Switching between two ui forms / QMainWindow screens



nitks.abhinav
22nd September 2017, 19:34
Hi,

I am building a QT application (QT4.8), where it has two ui forms, two threads one is main/GUI thread and other is worker thread with timer running.

It has one Base class derived from QObject, and two other classes for ui screens derived from QMainWindow. Base class contains the pointers for ui classes.


What is required is when application loads it should display the first screen , QMainWindow form , for that I am using show() function with CTOR of base class (shown below).

Now when timer in the thread goes off it calls the SIGNAL function in the base class and at that time it should switch to second ui or replace with second screen.

Issue:
First screen is shown properly but when it tries to switch to second screen within SIGNAL function, display becomes blank i.e. it goes off.

Any kind of help/suggestion is appreciated,

Thank you,


Code:
//CTOR
Base::Base()
{
qDebug() << "Base CTOR called\n";

//Show the first screen, loading raptor status
this->lrsGUI = new RaptorLrsGUI;
this->lrsGUI->setlabel(QString("Loading Status..."));
this->lrsGUI->showMaximized();
this->lrsGUI->show();

this->coreGUI = new RaptorCoreGUI;
}

/*SIGNAL function*/
void Base::rcvInitData()
{
qDebug()<< "Main Thread (CALLBACK): Swtch screen\n";

this->lrsGUI->hide();
this->coreGUI->setlabel(QString("Second Screen..."));
this->coreGUI->showMaximized();
this->coreGUI->show();
bootInitData = 1;

qDebug()<< "Main Thread (CALLBACK): EXiting Display initial screen\n";
}

d_stranz
23rd September 2017, 00:42
You are not creating either of these widgets with parents, therefore they will act as top-level windows. I assume that is what you want.

Calling both showMaximized() and show() is redundant. Both of these methods show the window, so if what you want is for the window to appear maximized on screen then call showMaximized() only.

This is not the way I would do it, however. You do not need the Base class at all. You probably don't need the worker thread either if all it is doing is firing a timer.

I would make one QMainWindow-based class, and use a QStackedWidget as its centralWidget. Add each of your GUI classes as pages in the stack. When the QMainWidget is constructed, set the current index for the stack to page 0 (your RaptorLrsGUI, derived from QWidget). Start the timer as a single shot in the MainWindow constructor and connect its timeout() signal to a MainWindow slot that switches the stack widget to index 1 (your RaptorCoreGUI class, also derived form QWidget).


display becomes blank i.e. it goes off.

Then you are probably doing something wrong in the code you haven't shown us.

nitks.abhinav
25th September 2017, 15:15
You are not creating either of these widgets with parents, therefore they will act as top-level windows. I assume that is what you want.

Calling both showMaximized() and show() is redundant. Both of these methods show the window, so if what you want is for the window to appear maximized on screen then call showMaximized() only.

This is not the way I would do it, however. You do not need the Base class at all. You probably don't need the worker thread either if all it is doing is firing a timer.

I would make one QMainWindow-based class, and use a QStackedWidget as its centralWidget. Add each of your GUI classes as pages in the stack. When the QMainWidget is constructed, set the current index for the stack to page 0 (your RaptorLrsGUI, derived from QWidget). Start the timer as a single shot in the MainWindow constructor and connect its timeout() signal to a MainWindow slot that switches the stack widget to index 1 (your RaptorCoreGUI class, also derived form QWidget).



Then you are probably doing something wrong in the code you haven't shown us.

Hi,

Thank you for reply, I am new to QT and this is kind of a PoC I am doing, this is what I want to achieve:
1) Keep two separate GUIs (ui forms).
2) When application starts, it should spawn a thread which will run timer and at the same time display first GUI on screen (happens in C'TOR).
3) When the timer of the thread goes off, it will emit its SIGNAL and SLOT function of main will get called which will stop the first GUI and replace with second one.

Below is the complete code(bit messy), I would appreciate if you could help in designing the above,

Files:
clientthread.h (worker thread)
coregui.h (second ui form/screen)
lsrgui.h (first ui form/screen)
base.h

clientthread.cpp
coregui.cpp
lsrgui.cpp
main.cpp

/clientthread.h/
class ClientThread : public QThread
{
Q_OBJECT

signals:
void sendInitData();
private:
void run();
QString m_lastTime;
private slots:
void timerHit();

};

/coregui.h/
namespace Ui {
class RaptorCoreGUI;
}

class RaptorCoreGUI : public QMainWindow
{
Q_OBJECT

public:
explicit RaptorCoreGUI(QWidget *parent = 0);
~RaptorCoreGUI();
void setlabel(QString);

private:
Ui::RaptorCoreGUI *ui;
};

/lsrgui.h/
namespace Ui {
class RaptorLrsGUI;
}

class RaptorLrsGUI : public QMainWindow
{
Q_OBJECT

public:
explicit RaptorLrsGUI(QWidget *parent = 0);
~RaptorLrsGUI();
void setlabel(QString);

private:
Ui::RaptorLrsGUI *ui;
};

/base.h/
class Base : public QObject
{
Q_OBJECT
public:
RaptorLrsGUI *lrsGUI;
RaptorCoreGUI *coreGUI;
QStackedWidget *stackedWidget;
Base();

private slots:
void rcvInitData();
void rcvLPNotif();
void rcvErrCounterInfo();
void rcvGenNotif();
};

**/clientthread.c /
void ClientThread::run()
{
QTimer timer;
connect(&timer, SIGNAL(timeout()), this, SLOT(timerHit()), Qt::DirectConnection);
timer.setInterval(5000);
timer.start(); // puts one event in the threads event queue
exec();
timer.stop();
}

void ClientThread::timerHit()
{
qDebug() << "Client Thread: Emitting sendMsg signal\n";
emit sendInitData();
}

/coregui.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)
{
ui->label->setText(label);
}

/lsrgui.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()
{
delete ui;
}

void RaptorLrsGUI::setlabel(QString label)
{
ui->label->setText(label);
}

/base.cpp/
Base::Base()
{
qDebug() << "Base CTOR called\n";

//Show the first screen, loading raptor status
this->lrsGUI = new RaptorLrsGUI;
this->lrsGUI->setlabel(QString("Loading Raptor Status..."));
this->lrsGUI->showMaximized();
this->lrsGUI->show();

//this->coreGUI = coreGUI;
this->coreGUI = new RaptorCoreGUI;
}

void Base::rcvInitData()
{
this->lrsGUI->hide();
this->coreGUI->setlabel(QString("Raptor Status..."));
this->coreGUI->setGeometry(480,272,-0,+128);
this->coreGUI->showMaximized();
this->coreGUI->show(); // ISSUE: DOES NOT SHOW THE SECOND GUI, BUT IF WE COMMENT OUT THE SHOW OF FIRST GUI (this->lrsGUI->show()),
THEN SECOND ONE IS SHOWN PROPERLY

qDebug()<< "Main Thread (CALLBACK): EXiting Display initial screen\n";
}

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
RaptorLrsGUI LrsGui;
RaptorCoreGUI CoreGui;

Base baseObj;

//instantiate Client thread object
ClientThread clientThread;

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;
}

d_stranz
25th September 2017, 17:22
You seem to be stuck on this design, which I have told you already is overly complicated for what you have said you want to do.

- You do not need a separate thread simply to send a timeout signal to switch UIs. All you need is a simple QTimer in QMainWindow.
- You should not have two different instances of QMainWindow. If you want to switch UIs, do that within a single QMainWindow instance using something like a QStackedWidget.
- Get rid of your Base class. It serves no purpose except to make your design more complex.

The simplified design should look like this:

- Derive a QMainWindow class.
- Derive two QWidget classes, one for each of your UIs.
- In the MainWindow constructor, create a QStackedWidget instance.
- call QMainWindow::setCentralWidget() with the QStackedWIdget pointer
- Create an instance of each of your UI classes.
- Add each instance to the QStackedWidget as pages 0 and 1
- Set the current stack widget index to 0
- Create a single-shot QTimer with a 5000 ms timeout, connect it to a MainWindow slot, and start the timer
- Exit the constructor
- In the timeout slot, set the stack widget index to 1 to show the other UI

That's all you need to do. No client thread, no Base class, no duplicate main windows, no calls to show(), showMaximized() or anything else.

Please see my signature below, and learn how to use CODE tags when posting source code. Your source code is unreadable otherwise.

nitks.abhinav
25th September 2017, 18:11
Hi,

Thank you very much for reply, I know that it can be done in a single shot thread , but as I told you this is not final design its just for PoC, main idea is to know how to switch screens.

I have changed the code as per your suggestion, but still I see only one ui screen all the time, below is the code:



Base::Base()
{
qDebug() << "Base CTOR called\n";

this->lrsGUI = new RaptorLrsGUI;
this->lrsGUI->setlabel(QString("Loading Status..."));
this->coreGUI = new RaptorCoreGUI;

this->stackedWidget = new QStackedWidget();
this->setCentralWidget(this->stackedWidget);
this->stackedWidget->addWidget(this->lrsGUI);
this->stackedWidget->addWidget(this->coreGUI);

this->stackedWidget->setCurrentIndex(0);

}

/* SLOT Fn */
void Base::rcvInitData()
{
this->stackedWidget->setCurrentIndex(1);
}

d_stranz
25th September 2017, 18:25
And what is "Base"? Is it now a QMainWindow class? You haven't called the QMainWindow constructor from your Base class constructor.

Have you run your program in the debugger? Did you set a breakpoint on line 21 to see if this slot is ever called?

nitks.abhinav
25th September 2017, 18:57
Base class is derived from QMainWindow as below:


class Base : public QMainWindow
{
Q_OBJECT
public:
RaptorLrsGUI *lrsGUI;
RaptorCoreGUI *coreGUI;
QStackedWidget *stackedWidget;
Base();

private slots:
void rcvInitData();

};


I have put the log in the SLOT function and I can see it getting printed:


void Base::rcvInitData()
{
qDebug()<< "Main Thread (CALLBACK): Display second screen\n";
this->stackedWidget->setCurrentIndex(1);
}



Base CTOR called

Client Thread: Connecting timer object timeout signal with threads timerhit slot

Client Thread: Starting timer objecti

Client Thread: executing clock thread

Client Thread: Emitting sendMsg signal

Main Thread (CALLBACK): Display second screen

Client Thread: Emitting sendMsg signal

Main Thread (CALLBACK): Display second screen

d_stranz
25th September 2017, 21:14
Client Thread: Emitting sendMsg signal

Main Thread (CALLBACK): Display second screen

Client Thread: Emitting sendMsg signal

Main Thread (CALLBACK): Display second screen

This is the thing that doesn't make any sense. Why would you have a QTimer emit a signal to show the same window more than once?

If this second window is not being shown, then you are doing something else wrong somewhere, and you haven't posted enough code to demonstrate what that is.

nitks.abhinav
25th September 2017, 21:48
I actually made it work by adding "stackedWidget->showMaximized();" after setCurrentIndex(0) in constructor. But still I have couple of issues

1) I could not set the backgroung color of widgets to white , even after doing "setStyleSheet("background-color:white;");".
This I temp resolved by deriving the ui classes from QMainWindow instead of QWidget.

2) I am not able to remove the titlebar from the window.

Below is the complete code:


/*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;
}

d_stranz
25th September 2017, 23:10
This I temp resolved by deriving the ui classes from QMainWindow instead of QWidget.

Do you understand that QMainWindow is supposed to be the only top-level window in your app, and that there is only supposed to be one instance of that class? You now have THREE classes that are derived from QMainWindow. QMainWindow is not a magic bullet class that you can derive anything from just to achieve some desired UI effect (like a different background color). And showMaximized() should never be called on a child window, only on a top-level window like QMainWindow.

QMainWindow is not just a widget, it defines a framework and a set of behaviors for applications with a single top-level window and many child windows within it. You cannot just simply use a QMainWindow anywhere you want without running into problems somewhere along the line because you haven't followed the rules.

I have no idea what types of classes "RaptorLrsGUI" and "RaptorCoreGUI" are. If they aren't derived from QWidget, then that is an error. If you have a custom paintEvent() in these classes, then that is where you should implement the code to fill the background with whatever color you want. If you do not have a paintEvent(), then in the constructor for these classes you should have code like this:



QPalette pal = palette(); // retrieves the default palette for the widget, as defined by the app's style
pal.setColor( QPalette::Window, Qt::white );
setPalette( pal );

setAutoFillBackground( true );


Setting the appropriate colors in the palette as well as ensuring that the widget automatically clears its background and fills it with the chosen color on a paintEvent() is the right way to do it.

I think you need to take a step back and look at some of the many examples in Qt for QMainWindow-based apps. If you continue down the path you are taking, your PoC is going to turn out to be a "proof of buggy code" that acts in ways you can't explain and is confusing to debug.

nitks.abhinav
26th September 2017, 16:25
Hi,
I very well know that QMainWindow is top level/parent window. That's what initially I did, when classes "RaptorLrsGUI" and "RaptorCoreGUI" are derived from QWidget and QStackedWidget is used , I don't see anything on screen, it goes blank. The below code is exactly as per suggested and it does not work.
Also I have changed the code to remove showMaximized on widget and use single shot timer.

Thanks for your patience..:-)


Base::Base(QWidget *parent) : QMainWindow(parent, Qt::FramelessWindowHint)
{
qDebug() << "Base CTOR called\n";

QPalette pal = palette(); // retrieves the default palette for the widget, as defined by the app's style
pal.setColor( QPalette::Window, Qt::white );
setPalette( pal );

setAutoFillBackground( true );

//Show the first screen, loading raptor status
lrsGUI = new RaptorLrsGUI; //RaptorLrsGUI derived from QWidget
lrsGUI->setlabel(QString("Loading Raptor Status..."));
coreGUI = new RaptorCoreGUI; //RaptorCoreGUI derived from QWidget

stackedWidget = new QStackedWidget();
stackedWidget->addWidget(lrsGUI);
stackedWidget->addWidget(coreGUI);

stackedWidget->setCurrentIndex(0);
}

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);
}


Rest of the code remain same as earlier.

d_stranz
26th September 2017, 17:44
You create the QStackedWidget, but you do not give it any parent. You do not tell your QMainWidget to use the QStackedWidget as its "centralWidget". Thus the QStackedWidget is never shown, so it is always invisible.

Line 16 should be:



stackedWidget = new QStackedWidget( this );


and add a line at the end of the constructor:


setCentralWidget( stackedWidget );


If you want the background of the Raptor* widgets to be white, this code needs to be moved to their constructors. It does nothing if you have it in the Base constructor:



QPalette pal = palette(); // retrieves the default palette for the widget, as defined by the app's style
pal.setColor( QPalette::Window, Qt::white );
setPalette( pal );


Edit: Actually, maybe this is incorrect. If you set the palette before creating the stacked and Raptor* widgets, it is possible that they will inherit the QPalette:: Window setting from the Base class.

nitks.abhinav
26th September 2017, 18:04
I made the changes the but still I can see white screen with title bar (screenshot attached) , below is the complete code.

Thanks you for all the help,



/Second UI */
namespace Ui {
class RaptorCoreGUI;
}

class RaptorCoreGUI : public QWidget
{
Q_OBJECT

public:
explicit RaptorCoreGUI(QWidget *parent = 0);
~RaptorCoreGUI();
void configInitData(bool);
void setlabel(QString);

private:
Ui::RaptorCoreGUI *ui;
};

/*First UI*/
amespace Ui {
class RaptorLrsGUI;
}

class RaptorLrsGUI : public QWidget
{
Q_OBJECT

public:
explicit RaptorLrsGUI(QWidget *parent = 0);
~RaptorLrsGUI();
void setlabel(QString);

private:
Ui::RaptorLrsGUI *ui;
};

/*Base class derived from QMainWindow*/
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) :
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) :
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*/
Base::Base(QWidget *parent) :
QMainWindow(parent, Qt::FramelessWindowHint)
{
qDebug() << "Base CTOR called\n";

QPalette pal = palette(); // retrieves the default palette for the widget, as defined by the app's style
pal.setColor( QPalette::Window, Qt::white );
setPalette( pal );

setAutoFillBackground( true );


//Show the first screen, loading raptor status
lrsGUI = new RaptorLrsGUI;
lrsGUI->setlabel(QString("Loading Raptor Status..."));
coreGUI = new RaptorCoreGUI;

stackedWidget = new QStackedWidget(this);
stackedWidget->addWidget(lrsGUI);
stackedWidget->addWidget(coreGUI);

stackedWidget->setCurrentIndex(0);
setCentralWidget(stackedWidget);
}

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;
}

d_stranz
26th September 2017, 18:13
I think we need to start from zero, because something is clearly wrong with what you are doing now.

Please write and run these two programs. You can simply comment out the lines in your current main.cpp and replace them with these lines:



#include <QtWidgets/QApplication>
#include "RaptorCoreGUI.h"

int main(int argc, char *argv[])
{
QApplication a(argc, argv);

RaptorCoreGUI w;
w.show();
return a.exec();
}




#include <QtWidgets/QApplication>
#include "RaptorLrsGUI.h"

int main(int argc, char *argv[])
{
QApplication a(argc, argv);

RaptorLrsGUI w;
w.show();
return a.exec();
}


In each case, do you see the windows you expect to see?

nitks.abhinav
26th September 2017, 18:31
Yes I can see the windows (attached)

IMG-4835 --> coreGUI
ING-4836 --> lrsGUI

d_stranz
26th September 2017, 20:28
OK, good. The problem is not with your Raptor* widgets.

Next step. Do you see the RaptorLrsGUI window when you run this code?



#include <QtWidgets/QApplication>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QStackedWidget>
#include "RaptorLrsGUI.h"

int main(int argc, char *argv[])
{
QApplication a(argc, argv);

QMainWindow w;
QStackedWidget * pStack = new QStackedWidget( &w );
RaptorLrsGUI * pLrs = new RaptorLrsGUI;
pStack->addWidget( pLrs );
w.setCentralWidget( pStack );
w.show();
return a.exec();
}

If it does, substitute "w.showMaximized()" for "w.show()". Does it still work?

nitks.abhinav
26th September 2017, 22:15
Yes, it does show same in both cases (show() and showMaximized()) as attached. Only label color is white rest is grey.

Added after 29 minutes:

Hi,

I got it work , I missed baseObj.show(); in main.

d_stranz
27th September 2017, 01:10
I got it work , I missed baseObj.show(); in main.

Good. I was afraid we would have to put your program together piece-by-piece until it finally worked.

nitks.abhinav
27th September 2017, 15:50
Thank you for all the help!