Results 1 to 2 of 2

Thread: QToolBar's extension menu in a QGraphicsScene

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default QToolBar's extension menu in a QGraphicsScene

    I use a QToolBar in a QGraphicsScene and I'm having some trouble with the extension menu.

    In the QToolBar documentation it says:

    When a QToolBar is not a child of a QMainWindow, it looses the ability to populate the extension pop up with widgets added to the toolbar using addWidget(). Please use widget actions created by inheriting QWidgetAction and implementing QWidgetAction::createWidget() instead.
    I use QToolButtons created in QWidgetActions and they are working as expected.

    I use the Qt::BypassGraphicsProxyWidget flag in the QToolBar so that the extension menu doesn't get embedded in a QGraphicsProxyWidget when created and displayed. When the QToolBar is resized small enough so that some of the actions in the QToolBar is hidden, the extension button appears.

    The problem I'm having is that the extension menu pops up in the wrong position on the screen (far to the left of where the QToolBar is in the QGraphicsScene) and I have no way of positioning it from within my code.

    Is there a way to know when the extension menu is about to show or shown and a way to access it? That way I can create and position my own QMenu with the hidden actions in.

    Is there an easier way to do this?

    Any help is greatly appreciated,
    Francois

    EDIT: I forgot to mention that when I don't use the Qt::BypassGraphicsProxyWidget flag, the extension menu pops up in the correct position on the graphics scene but underneath other items. An alternative acceptable solution would be if I can somehow force it to the top of the scene's z-order
    Last edited by francoisjj; 5th September 2011 at 16:13.

  2. #2

    Default Re: QToolBar's extension menu in a QGraphicsScene

    For anyone that is interested, I managed to solve this in a very hacky way.

    I iterate through the toolbar's children and then through the children's children (I went through the source code to see how the extension menu is parented). I then connect their aboutToShow() signal to a slot so that I can access the QMenu through the sender() function. I am then able to move the menu where I want it.

    If anyone has a better solution, I am all ears.

Similar Threads

  1. Replies: 5
    Last Post: 6th November 2012, 20:42
  2. QMake Target extension
    By gregg in forum Qt Tools
    Replies: 2
    Last Post: 28th February 2011, 18:18
  3. using qmotif extension
    By pascasio in forum Newbie
    Replies: 7
    Last Post: 30th November 2010, 13:53
  4. Drag & Drop and Context Menu problem QGraphicsScene
    By onurozcelik in forum Qt Programming
    Replies: 0
    Last Post: 19th August 2010, 08:12
  5. Using Qt with kernel extension dll
    By ramazangirgin in forum Qt Programming
    Replies: 1
    Last Post: 21st January 2008, 13: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
  •  
Qt is a trademark of The Qt Company.