Results 1 to 4 of 4

Thread: Open or close?

  1. #1
    Join Date
    Jul 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X

    Post Open or close?

    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!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Open or close?

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Open or close?

    Quote Originally Posted by isaias1984
    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

  4. #4
    Join Date
    Jul 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Open or close?

    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.

Similar Threads

  1. Replies: 3
    Last Post: 26th May 2011, 13:29
  2. open-close-suspend-resume mouse functions in QWSServer
    By masterbraind in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 9th November 2010, 21:07
  3. How to close QMainWindow and open login dialog
    By keeyias in forum Qt Programming
    Replies: 3
    Last Post: 15th October 2009, 12:33
  4. How to Open & Close a Widget ?!!
    By Fatla in forum Qt Programming
    Replies: 6
    Last Post: 13th June 2008, 20:39
  5. fstream open/close
    By mickey in forum General Programming
    Replies: 4
    Last Post: 13th October 2006, 12:23

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.