Qt-interest Archive, May 2008
PARTIAL MODAL QDIALOG
Message 1 in thread
Hi,
I am stuck with the following situation:
I am writing a CAD application, so my main widget is a subclass of
QGLWidget. Now, say that my application is performing checkings in the
geometry and needs to ask a question to the
user (Yes or No) in order to perform a specific action.
By default, i would display a modal dialog or messagebox and wait until the
user answers the question, then i would continue the rest of the checkings.
However, i want the user to be able to interact with the QGLWidget
(rotating, translating, zooming, etc) when the dialog is displayed (so the
user can examine the geometry before answering the dialog's question). But a
modal dialog would prevent the user from interacting with the QGLWidget. I
know, i can display a modeless dialog and catch its finished() signal in
order to continue the operations. However, the problem is that it is a bit
tricky to keep status of the current state of the operations in order to be
able to continue them and in addition i want the user
to be able to interact only with the QGLWidget and not any other widget,
menu, toolbars etc!!!!
Any suggestions?
Thanks in advance,
Panos
Message 2 in thread
"Panagiotis Antonellis" <adonel@xxxxxxxxx> wrote in message news:903a201a0805130123x24bd107bhf9d1ad1565efa21@xxxxxxxxxxxxxxxxx
I am writing a CAD application, so my main widget is a subclass of QGLWidget. Now, say that my application is performing checkings in the geometry and needs to ask a question to the
user (Yes or No) in order to perform a specific action.
By default, i would display a modal dialog or messagebox and wait until the user answers the question, then i would continue the rest of the checkings. However, i want the user to be able to interact with the QGLWidget (rotating, translating, zooming, etc) when the dialog is displayed (so the user can examine the geometry before answering the dialog's question). But a modal dialog would prevent the user from interacting with the QGLWidget. I know, i can display a modeless dialog and catch its finished() signal in order to continue the operations. However, the problem is that it is a bit tricky to keep status of the current state of the operations in order to be able to continue them and in addition i want the user
to be able to interact only with the QGLWidget and not any other widget, menu, toolbars etc!!!!
Hi Panos,
Interesting problem!
What you perhaps could try is something like this:
Assuming you have all your actions in your application defined using QAction objects, you can build a list of these somewhere (QList<QAction*>). Now, create a function that builds a QHash<QAction*, bool> to store the current enabled state of your actions. You can either just save that hash, or put it on a stack in case you want to make is it possible to do this several times on top of each other. Now, disable all the actions from your list of actions (call ->setEnabled(false) on every item in your actions list), and re-enable the actions you need to navigate your QGLWidget. After you have the finished() signal from your dialog, you can restore the previous state from your hash with the previous values.
I hope this idea helps you.
André


Message 3 in thread
Thanks Andre,
I will try your idea. However, your solution doesn't solve my problem for
restoring the state of my checkings.
What i would like is to display the dialog as a modeless dialog, but have my
computations block unit the dialog is finished, and then continue!!! I know
that probably this is not possible, but i am wondering if everyone has run
into a similar situation before.
Panos
On Tue, May 13, 2008 at 11:49 AM, André Somers <andre@xxxxxxxxxxxxxxxx>
wrote:
> "Panagiotis Antonellis" <adonel@xxxxxxxxx> wrote in message
> news:903a201a0805130123x24bd107bhf9d1ad1565efa21@xxxxxxxxxxxxxxxxx
> I am writing a CAD application, so my main widget is a subclass of
> QGLWidget. Now, say that my application is performing checkings in the
> geometry and needs to ask a question to the
> user (Yes or No) in order to perform a specific action.
> By default, i would display a modal dialog or messagebox and wait until
> the user answers the question, then i would continue the rest of the
> checkings. However, i want the user to be able to interact with the
> QGLWidget (rotating, translating, zooming, etc) when the dialog is displayed
> (so the user can examine the geometry before answering the dialog's
> question). But a modal dialog would prevent the user from interacting with
> the QGLWidget. I know, i can display a modeless dialog and catch its
> finished() signal in order to continue the operations. However, the problem
> is that it is a bit tricky to keep status of the current state of the
> operations in order to be able to continue them and in addition i want the
> user
> to be able to interact only with the QGLWidget and not any other widget,
> menu, toolbars etc!!!!
>
> Hi Panos,
>
> Interesting problem! [image: Smile emoticon]
>
> What you perhaps could try is something like this:
> Assuming you have all your actions in your application defined using
> QAction objects, you can build a list of these somewhere (QList<QAction*>).
> Now, create a function that builds a QHash<QAction*, bool> to store the
> current enabled state of your actions. You can either just save that hash,
> or put it on a stack in case you want to make is it possible to do this
> several times on top of each other. Now, disable all the actions from your
> list of actions (call ->setEnabled(false) on every item in your actions
> list), and re-enable the actions you need to navigate your QGLWidget. After
> you have the finished() signal from your dialog, you can restore the
> previous state from your hash with the previous values.
>
> I hope this idea helps you.
>
> André
>
>
>


Message 4 in thread
"Panagiotis Antonellis" <adonel@xxxxxxxxx> wrote in message news:903a201a0805130231k5272d31aj849d66169d151d19@xxxxxxxxxxxxxxxxx
Thanks Andre,
I will try your idea. However, your solution doesn't solve my problem for restoring the state of my checkings.
What i would like is to display the dialog as a modeless dialog, but have my computations block unit the dialog is finished, and then continue!!! I know that probably this is not possible, but i am wondering if everyone has run into a similar situation before.
Hi Panos,
I guess your description of your problem is not quite clear then. I was under the impression that you just wanted to prevent the user from triggering actions during the time your dialog is shown, but obviously you want to do more than that. What kind of computations would you like to block? Are they running in the background? Maybe you can give some more explanation on what you are trying to do?
If you mean that your dialog is triggered by a compation, and you want to hold that computation while the user responds, maybe you can use the Qxt library. Specifically, you may be interested in the QxtSignalWaiter class: http://docs.libqxt.org/classQxtSignalWaiter.html. This class allows you to block the execution of a piece of code untill you receive a specified signal. Of course, you can also try to split your computation over several methods, but that may be harder to do.
Regards,
André
P.S. Please *only* reply to the mailinglist/newsgroup. I will see a reply there and respond if and when I have the opportunity (and feel like it).
Message 5 in thread
On Tuesday 13 May 2008 11:31:48 Panagiotis Antonellis wrote:
> Thanks Andre,
> I will try your idea. However, your solution doesn't solve my problem for
> restoring the state of my checkings.
> What i would like is to display the dialog as a modeless dialog, but have
> my computations block unit the dialog is finished, and then continue!!! I
> know that probably this is not possible, but i am wondering if everyone has
> run into a similar situation before.
An easy solution is to start a QEventLoop in your (modeless) dialogs show
method - and exit this eventloop when you want to return control back to your
calling code.
Frank
--
[ signature omitted ]
Message 6 in thread
Hi,
So in order to be clear:
The dialog is triggered by a computation, so i want to block the computation
until the user answers the specific question!
I will take a look at the Qxt library.
As far as the suggestion to start a QEventLoop in the (modeless) dialog, i
think that doing so will prevent the user from interacting
with the QGlWidget, am i right?
Panos
On Tue, May 13, 2008 at 1:48 PM, Frank Hemer <frank@xxxxxxxxx> wrote:
> On Tuesday 13 May 2008 11:31:48 Panagiotis Antonellis wrote:
> > Thanks Andre,
> > I will try your idea. However, your solution doesn't solve my problem
> for
> > restoring the state of my checkings.
> > What i would like is to display the dialog as a modeless dialog, but
> have
> > my computations block unit the dialog is finished, and then continue!!!
> I
> > know that probably this is not possible, but i am wondering if everyone
> has
> > run into a similar situation before.
>
> An easy solution is to start a QEventLoop in your (modeless) dialogs show
> method - and exit this eventloop when you want to return control back to
> your
> calling code.
>
> Frank
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
Message 7 in thread
On Tuesday 13 May 2008 13:00:30 Panagiotis Antonellis wrote:
> Hi,
> So in order to be clear:
> The dialog is triggered by a computation, so i want to block the
> computation until the user answers the specific question!
> I will take a look at the Qxt library.
> As far as the suggestion to start a QEventLoop in the (modeless) dialog, i
> think that doing so will prevent the user from interacting
> with the QGlWidget, am i right?
I have no experience with QLlWidget, however this allows to interact with
other dialogs and your dialog will stay modeless, so this will not prevent
user interaction.
Frank
--
[ signature omitted ]
Message 8 in thread
> From: Panagiotis Antonellis [mailto:adonel@xxxxxxxxx]
> Sent: Tuesday, May 13, 2008 3:24 AM
> To: qt-interest@xxxxxxxxxxxxx
> Subject: PARTIAL MODAL QDIALOG
>
> Hi,
>
> I am stuck with the following situation:
>
> I am writing a CAD application, so my main widget is a subclass of
> QGLWidget. Now, say that my application is performing checkings in the
> geometry and needs to ask a question to the
> user (Yes or No) in order to perform a specific action.
> By default, i would display a modal dialog or messagebox and wait until
> the user answers the question, then i would continue the rest of the
> checkings.
> However, i want the user to be able to interact with the QGLWidget
> (rotating, translating, zooming, etc) when the dialog is displayed (so the
> user can examine the geometry before answering the dialog's question). But
> a modal dialog would prevent the user from interacting with the QGLWidget.
> I know, i can display a modeless dialog and catch its finished() signal in
> order to continue the operations.
I think I may have a simple solution for you. Create your own custom
message box as a QDialog. Assuming you do not want the close "X" or the
dialog menu, I would set the dialog flags as so:
"yourCustomMsgBox->setWindowFlags(Qt::Dialog | Qt::WindowStaysOnTopHint |
Qt::WindowTitleHint );".
This will force the user to interact with your "Yes"/"No" buttons (without
the ability to close it from the "X") while keeping this dialog on top of
the QGLWidget window. The WindowTitleHint will allow the user to move the
custom message around so they can interact with the QGLWidget window. You
could even have the custom message parent as the QGLWidget window by doing
the following (where "this" is the QGLWidget window):
yourCustomMsgBox theMsg(this);
theMsg.setParent(this, Qt::Dialog | Qt::WindowStaysOnTopHint |
Qt::WindowTitleHint);
theMsg.exec();
> However, the problem is that it is a bit tricky to keep status of the
> current state of the operations in order to
> be able to continue them and in addition i want the user
> to be able to interact only with the QGLWidget and not any other widget,
> menu, toolbars etc!!!!
Again, this seems simple. I assume that since you have toolbars and menus
that you have a createActions() function. If you have actions, then you
should have an updateActions() function as well that set the enable/disable
status of the actions. You can create the updateActions function however
you wish, so if you want, then pass it an integer or Boolean that is used to
determine which actions to enable/disable.
void MainWindow::updateActions( bool bDisableAll )
{
yourActions->setEnabled( bDisableAll );
...
}
If the updateActions function is part of the MainWindow, then make it public
and call it when yourCustomMsgBox is opened like so:
yourCustomMsgBox theMsg(this);
theMsg.setParent(this, Qt::Dialog | Qt::WindowStaysOnTopHint |
Qt::WindowTitleHint);
mainWinPointer->updateActions( true );
theMsg.exec();
I may be way off, but this is how I would approach it.
Michael
--
[ signature omitted ]
Message 9 in thread
Michael thans for your reply,
However, i think that if i call:
theMsg.exec(),
then my application will block and the user won't be able to interact with
the QGLWidget!
I think that my problem is that i want a "modeless" dialog that will block
my execution of operations...
So i need a waitForSignal() function that will wait for the modeless dialog
to close and then continue with the rest of the
checkings/operations!
The QxT library has a similar class, so probably i will try it...
Panos
On Tue, May 13, 2008 at 5:31 PM, Michael Booker <
michael.booker@xxxxxxxxxxxxxxxxxxxx> wrote:
> > From: Panagiotis Antonellis [mailto:adonel@xxxxxxxxx]
> > Sent: Tuesday, May 13, 2008 3:24 AM
> > To: qt-interest@xxxxxxxxxxxxx
> > Subject: PARTIAL MODAL QDIALOG
> >
> > Hi,
> >
> > I am stuck with the following situation:
> >
> > I am writing a CAD application, so my main widget is a subclass of
> > QGLWidget. Now, say that my application is performing checkings in the
> > geometry and needs to ask a question to the
> > user (Yes or No) in order to perform a specific action.
> > By default, i would display a modal dialog or messagebox and wait until
> > the user answers the question, then i would continue the rest of the
> > checkings.
> > However, i want the user to be able to interact with the QGLWidget
> > (rotating, translating, zooming, etc) when the dialog is displayed (so
> the
> > user can examine the geometry before answering the dialog's question).
> But
> > a modal dialog would prevent the user from interacting with the
> QGLWidget.
> > I know, i can display a modeless dialog and catch its finished() signal
> in
> > order to continue the operations.
>
> I think I may have a simple solution for you. Create your own custom
> message box as a QDialog. Assuming you do not want the close "X" or the
> dialog menu, I would set the dialog flags as so:
> "yourCustomMsgBox->setWindowFlags(Qt::Dialog | Qt::WindowStaysOnTopHint |
> Qt::WindowTitleHint );".
> This will force the user to interact with your "Yes"/"No" buttons (without
> the ability to close it from the "X") while keeping this dialog on top of
> the QGLWidget window. The WindowTitleHint will allow the user to move the
> custom message around so they can interact with the QGLWidget window. You
> could even have the custom message parent as the QGLWidget window by doing
> the following (where "this" is the QGLWidget window):
>
> yourCustomMsgBox theMsg(this);
> theMsg.setParent(this, Qt::Dialog | Qt::WindowStaysOnTopHint |
> Qt::WindowTitleHint);
> theMsg.exec();
>
> > However, the problem is that it is a bit tricky to keep status of the
> > current state of the operations in order to
> > be able to continue them and in addition i want the user
> > to be able to interact only with the QGLWidget and not any other widget,
> > menu, toolbars etc!!!!
>
> Again, this seems simple. I assume that since you have toolbars and menus
> that you have a createActions() function. If you have actions, then you
> should have an updateActions() function as well that set the
> enable/disable
> status of the actions. You can create the updateActions function however
> you wish, so if you want, then pass it an integer or Boolean that is used
> to
> determine which actions to enable/disable.
>
> void MainWindow::updateActions( bool bDisableAll )
> {
> yourActions->setEnabled( bDisableAll );
> ...
> }
>
> If the updateActions function is part of the MainWindow, then make it
> public
> and call it when yourCustomMsgBox is opened like so:
>
> yourCustomMsgBox theMsg(this);
> theMsg.setParent(this, Qt::Dialog | Qt::WindowStaysOnTopHint |
> Qt::WindowTitleHint);
> mainWinPointer->updateActions( true );
> theMsg.exec();
>
> I may be way off, but this is how I would approach it.
>
> Michael
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>