PDA

View Full Version : Create and Use a status dialog



JAD
26th January 2016, 20:46
I would like to create and use a dialog to hold user and application status. Similar in nature to the progress bar, but using words. The dialog itself is is a QTextEdit set to read-only. What would be the best way to get information to the dialog, both from other Qt dialogs (e.g. mouse pick information) and analysis code (e.g. information where at in an algorithm).

Thanks!

d_stranz
26th January 2016, 21:29
I would implement slots in the dialog to receive information and update the dialog's text. Create signals in the application that are emitted when the status changes. When you create the dialog, connect those signals to the proper slots in the dialog.

When you show the dialog, be sure you do it using show() and not exec(), otherwise the dialog will be modal and you will not be able to interact with anything else in your app.

JAD
29th January 2016, 16:23
Thanks.

I am attempting to do this with some success.

I am able to emit a int or QString signal from a QCLWidget and the slot is called.

When I emit the same int and QString signals from another dialog nothing happens.

The signals, emit() and connect() are set the same.

extern DisplayOptionsDialog * displayOptionsDialog;
extern GLWidget *glWidget;

connect(displayOptionsDialog, SIGNAL(updateStatus(QString)), this, SLOT(WriteStatus(QString))):
connect(displayOptionsDialog, SIGNAL(updateStatus2(int)), this, SLOT(WriteStatus2(int)));

connect(glWidget, SIGNAL(updateStatus(QString)), this, SLOT(WriteStatus(QString))):
connect(glWidget, SIGNAL(updateStatus2(int)), this, SLOT(WriteStatus2(int)));

Thanks!

Added after 1 5 minutes:

I figured it out, the displayOptionsDialog wasn't yet created. This is how:

I am using Visual Studio 2013. In Debug Configuration

Right click on application -> Properties -> Configuration Properties -> Debugging -> Environment -> <Edit...>

Add the line:

QT_FATAL_WARNINGS=1

I then ran the program in debug, no breaks set. It broke on the line connect(displayOptionsDialog,...) line and which allowed me to interrogate the variables and see that displayOptionsDialog hadn't been created.

d_stranz
29th January 2016, 16:30
Insufficient information. I presume you mean that the "DisplayOptionsDialog" is the one that doesn't work.

1 - When the dialog instance is shown, is is modal (invoked using exec()) or non-modal (invoked using show())? If it is modal, it is running its own event loop and blocking the app's event loop.
2 - Are the pointers correct? I.e. are they pointing to the instances you think they are?
3 - Does the class definition declare updateStatus() and updateStatus2() in a "signals:" section?

---
In response to your edit, then the problem was addressed by my question #2.