PDA

View Full Version : Open or close?



isaias1984
6th July 2011, 11:03
Hello.

Using QPlainTextEdit class that provides a widget that I used to edit and display plain text I have created a separate window from my main program. Now I want to create an action in the main program window tab who tells me if the text window is open or closed. I find no function in the class QPlainTextEdit that resembles the one I used with other widgets I have on my main window (function toggleViewAction, QDockWidget class). Does anyone know what can I use?

Thanks!

wysota
6th July 2011, 11:19
Subclass the widget class and reimplement its showEvent() and hideEvent(). In the reimplementation adjust the checked property of an internal action that you can return to the user just like toggleViewAction() does for QDockWidget.

Santosh Reddy
7th July 2011, 05:37
Now I want to create an action in the main program window tab who tells me if the text window is open or closed
Not very clear (to me)..

1. Do you want a status icon (action) to show the visibility status of the QPlainTextEdit widget, then you can do as suggested above. If you don't want to sub-class then, can use QWidget::isVisible() to make decisions (or) install a event filter, and check for show event and hide event.

or

2.. Do you want the QPlainTextEdit to be visible or hidden when you trigger the action on tool bar, then you can use the QWidget::setVisible() slot

isaias1984
12th July 2011, 12:31
Thank wysota, I'll try this. And Santos Reddy is the first one, I want to add a status icon (an action) to show the visibility status of the QPlainTextEdit widget. Thanks for your replys.