Results 1 to 3 of 3

Thread: Disable the QToolBar when the QMenuBar gets disabled?

  1. #1
    Join Date
    Nov 2009
    Location
    Sweden
    Posts
    34
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Disable the QToolBar when the QMenuBar gets disabled?

    Hi,
    In my application (in the QMainWindow) I use a QMenuBar and a QToolBar. When other widgets than my QMainWindow (typically QDialog:s, even such that are not Modal) are "focused", in general the QMenuBar is automatically "disabled". The QMenuBar gets enabled again when the other widget is closed, or when "activating"/"focusing" the QMainWindow. This is some kind of default behaviour of the QMenuBar in my QMainWindow, and I would very much like my QToolBar to behave in the same way - to "disable" it when for example a QDialog opens (and are focused), to prevent the user from thinking that he/she can use the ToolButtons all the time.

    I've tried changing the QMainWindow:s 'focusInEvent' and 'focusOutEvent', but I did not succeed in "capturing" the correct behaviour. The QMenuBar:s enable/disable state does not seem to be precisely correlated to the focus state od the QMainWindow. Or did I just not succed?

    In other word - is there a way of having the QToolBar:s enabled/disabled state "following" the enabled/disabled state of the QMenuBar???

  2. #2
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Disable the QToolBar when the QMenuBar gets disabled?

    Go thru,

    qwidget::setFocusPolicy

    qwidget::setFocus


    If you want user not to use any toolbuttons, just disable the toolbar if focus is out of the mainwindow. If you want to handle QToolBar's event in mainwindow, Try using http://doc.trolltech.com/4.6/qobject...allEventFilter

  3. #3
    Join Date
    Nov 2009
    Location
    Sweden
    Posts
    34
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Disable the QToolBar when the QMenuBar gets disabled?

    Well, the thing is that I'd already tried using the focusInEvent()/focusOutEvent(), but it seems that the QMainWindow does not actually "focusOut" when I, for example, open a QDialog, and so it does not "focusIn" if I close the dialog.

    Could there be other ways of solving this?

Similar Threads

  1. QMenuBar or QToolBar Logo
    By ^NyAw^ in forum Qt Programming
    Replies: 6
    Last Post: 3rd November 2009, 14:31
  2. Loading disabled icons
    By user_mail07 in forum Qt Programming
    Replies: 3
    Last Post: 12th June 2007, 20:19
  3. Shorcuts for disabled QActions
    By Michiel in forum Qt Programming
    Replies: 2
    Last Post: 23rd May 2007, 16:49
  4. Why the system buttons are disabled on Mac OS?
    By gtthang in forum Qt Programming
    Replies: 2
    Last Post: 3rd May 2007, 09:50

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.