Results 1 to 13 of 13

Thread: Painting primitive elements-PanelMenu does not show

  1. #1
    Join Date
    Sep 2008
    Location
    Poland
    Posts
    80
    Thanks
    4
    Thanked 5 Times in 4 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Painting primitive elements-PanelMenu does not show

    Hi Brothers

    Why the code below does not work?I mean,only the frame is painted.
    parallelMenu is a descendant of QWidget.
    Qt Code:
    1. void parallelMenu::paintEvent(QPaintEvent *e)
    2. {
    3. QPainter p(this);
    4.  
    5. menuOpt.initFrom(this);//the rect is set in the constructor by setGeometry
    6.  
    7. QStyle *s=style();
    8.  
    9. s->drawPrimitive(QStyle::PE_PanelMenu,&menuOpt,&p);
    10. s->drawPrimitive(QStyle::PE_FrameMenu,&menuOpt,&p);
    11. }
    To copy to clipboard, switch view to plain text mode 

  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: Painting primitive elements-PanelMenu does not show

    What is the exact effect you are trying to achieve?
    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
    Sep 2008
    Location
    Poland
    Posts
    80
    Thanks
    4
    Thanked 5 Times in 4 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Painting primitive elements-PanelMenu does not show

    I'd like to create a popup menu with QAction laying in X parallel columns.
    Unfortunetly,there is no such functionality in QMenu (except those when menu exceeds height of the screen,but I can't force to use it)

    So I think there is no other way than create my own QParallelMenu from QWidget

  4. #4
    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: Painting primitive elements-PanelMenu does not show

    I mean what is the reason for trying to perform those drawing operations.
    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.


  5. #5
    Join Date
    Sep 2008
    Location
    Poland
    Posts
    80
    Thanks
    4
    Thanked 5 Times in 4 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Painting primitive elements-PanelMenu does not show

    I want to draw menu using QStyle by using it's 'bricks':
    http://doc.qt.nokia.com/4.6/style-reference.html#menus

    But when I use drawPrimitive(QStyle::PE_PanelMenu,&menuOpt,&p); the panel is not drawn

  6. #6
    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: Painting primitive elements-PanelMenu does not show

    QMenu itself only draws PE_PanelMenu and CE_MenuItems, it doesn't call PE_FrameMenu.

    Qt Code:
    1. menuOpt.initFrom(this);
    2. menuOpt.state = QStyle::State_None;
    3. menuOpt.checkType = QStyleOptionMenuItem::NotCheckable;
    4. menuOpt.maxIconWidth = 0;
    5. menuOpt.tabWidth = 0;
    6. style()->drawPrimitive(QStyle::PE_PanelMenu, &menuOpt, &p, this);
    To copy to clipboard, switch view to plain text mode 
    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.


  7. #7
    Join Date
    Sep 2008
    Location
    Poland
    Posts
    80
    Thanks
    4
    Thanked 5 Times in 4 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Painting primitive elements-PanelMenu does not show

    I tried this orginal QMenu code-it does not work.And about painting the frame-look down inside QMenu:aintEvent() :]

  8. #8
    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: Painting primitive elements-PanelMenu does not show

    Quote Originally Posted by MasterBLB View Post
    I tried this orginal QMenu code-it does not work.
    What do you mean it doesn't work? Try surrounding the call with QPainter::save() and QPainter::restore().
    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.


  9. #9
    Join Date
    Sep 2008
    Location
    Poland
    Posts
    80
    Thanks
    4
    Thanked 5 Times in 4 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Painting primitive elements-PanelMenu does not show

    I mean that only the frame is visible,while I expected an plain,empty space.

  10. #10
    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: Painting primitive elements-PanelMenu does not show

    Could you provide a mockup picture of what you wanted to obtain and what you did obtain?
    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.


  11. #11
    Join Date
    Sep 2008
    Location
    Poland
    Posts
    80
    Thanks
    4
    Thanked 5 Times in 4 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Painting primitive elements-PanelMenu does not show

    Sure,there is is.
    As you can see,element QStyle::CE_MenuEmptyArea,as well as QStyle::PE_PanelMenu is not drawn-only the frame is visible.

    Although I managed to develop a solution at least-I draw a large QStyle::CE_MenuItem without neither text nor icon,and then paint test items on it.
    But still,I don't know why the orginal code does not work.
    Attached Images Attached Images

  12. #12
    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: Painting primitive elements-PanelMenu does not show

    At least for me the image is not helpful in any way, you provided an image of the whole screen and I wanted two small pictures one of which points to what you get and the other to what you would like to get.
    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.


  13. #13
    Join Date
    Sep 2008
    Location
    Poland
    Posts
    80
    Thanks
    4
    Thanked 5 Times in 4 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Painting primitive elements-PanelMenu does not show

    Ok wysota,but in that case you have to wait 'till I come back from work to home.

Similar Threads

  1. Ui Elements (QLineEdit) + QML
    By NoRulez in forum Qt Programming
    Replies: 1
    Last Post: 3rd April 2010, 16:04
  2. Cutting Elements QStringlist
    By codeman in forum Qt Programming
    Replies: 3
    Last Post: 5th June 2009, 11:19
  3. elements not updated
    By danesh in forum Qt Programming
    Replies: 2
    Last Post: 2nd April 2009, 08:35
  4. Replies: 11
    Last Post: 2nd August 2007, 20:31
  5. Elements out of Range!!
    By Kapil in forum Newbie
    Replies: 9
    Last Post: 3rd April 2006, 10:28

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.