December 29, 2011

TonyR TonyR
Lab Rat
15 posts

Change trinagle in the menu button

Page  
1

When the popup menu is associateed with push button in some styles we can see will produce a small triangle to the right of the button’s text. How we can change this triangle?

19 replies

December 29, 2011

Rahul Das Rahul Das
Robot Herder
360 posts

you mean a tool tip ? You could post here a screen shot too..

 Signature 

——————————-

    Rahul Das

——————————-

December 29, 2011

TonyR TonyR
Lab Rat
15 posts

Menu button

You can see it the documentation for QPushButton

  1. void QPushButton::setMenu ( QMenu * menu )

December 29, 2011

Rahul Das Rahul Das
Robot Herder
360 posts

Doc also says that,in some styles it will produce a small triangle to the right of the button’s text. I afraid, we can’t control drawing that triangle.

 Signature 

——————————-

    Rahul Das

——————————-

December 29, 2011

fluca1978 fluca1978
Ant Farmer
524 posts

The appearance is driven by the style in use, so you have to deal with the windowing style. I don’t think this is possible without implementing a new style.

December 29, 2011

Andre Andre
Area 51 Engineer
6031 posts

You could try creating a QProxyStyle and reimplementing QStyle::standardItemImplementation() to return whatever you need when the SP_ArrowDown pixmap is requested. However, I am not sure that this is actually used by all styles, nor that this is the right pixmap. YMMV

 Signature 

Looking for Qt developers to join our team @ i-Optics: https://qt-project.org/forums/viewthread/25393/

December 29, 2011

TonyR TonyR
Lab Rat
15 posts

Andre wrote:
You could try creating a QProxyStyle and reimplementing QStyle::standardItemImplementation()

Interesting idea, but I don’t found QStyle::standardItemImplementation()

December 29, 2011

Chris H Chris H
Lab Rat
139 posts

I think he means standardIconImplementation [developer.qt.nokia.com]

December 30, 2011

Andre Andre
Area 51 Engineer
6031 posts

Yeah, sorry, that’s what I mend.

 Signature 

Looking for Qt developers to join our team @ i-Optics: https://qt-project.org/forums/viewthread/25393/

December 30, 2011

BlackJack BlackJack
Lab Rat
22 posts

Hello
I have a similar problem.
You need to replace the standard icon, on the other

I created a new class inherited from QProxyStyle and redefined method standardIconImplementation, but for some reason I will not have changed…

  1. class CustomStyle :
  2.     public QProxyStyle
  3. {
  4.     Q_OBJECT
  5. public:
  6.     CustomStyle();
  7.  
  8. protected slots:
  9.     QIcon standardIconImplementation(StandardPixmap standardIcon,
  10.                                                   const QStyleOption *option,
  11.                                                   const QWidget *widget) const;
  12. };

and the implementation itself
  1. QIcon CustomStyle::standardIconImplementation(StandardPixmap standardIcon,
  2.                                                   const QStyleOption *option,
  3.                                                   const QWidget *widget) const
  4. {
  5.     switch(standardIcon)
  6.     {
  7.         case QStyle::SP_TitleBarMenuButton:
  8.             return QIcon(":/image/circle_middle.png");
  9.         case QStyle::SP_ArrowDown:
  10.             return QIcon(":/image/circle_middle.png");
  11.         case QStyle::SP_CommandLink:
  12.             return QIcon(":/image/circle_middle.png");
  13.     }
  14.     return QProxyStyle::standardIconImplementation(standardIcon, option, widget);
  15.  
  16. }

January 4, 2012

BlackJack BlackJack
Lab Rat
22 posts

that no one will help me not? :(

January 4, 2012

Andre Andre
Area 51 Engineer
6031 posts

Is your method actually called? Are you sure your proxy style is used as the style for the application?

 Signature 

Looking for Qt developers to join our team @ i-Optics: https://qt-project.org/forums/viewthread/25393/

January 4, 2012

BlackJack BlackJack
Lab Rat
22 posts

Yes it is connected and is the default style

  1. #include "customstyle.h"
  2. #include "widget.h"
  3.  
  4. int main(int argc, char *argv[])
  5. {    
  6.     QApplication a(argc, argv);
  7.  
  8.     a.setStyle(new CustomStyle());
  9.  
  10.     Widget w;   w.show();
  11.  
  12.     return a.exec();
  13. }

January 4, 2012

Andre Andre
Area 51 Engineer
6031 posts

Are you sure as in: you inserted some debug statement in your QProxyStyle-derived class and you actually get the debug output?

 Signature 

Looking for Qt developers to join our team @ i-Optics: https://qt-project.org/forums/viewthread/25393/

January 4, 2012

BlackJack BlackJack
Lab Rat
22 posts

In the debugger, there is some reason only one event where:

standardIcon = QStyle:: SP_CommandLink (56)

and nothing else happens, comes only once in the function

  1. QIcon CustomStyle::standardIconImplementation(StandardPixmap standardIcon,
  2.                                                   const QStyleOption *option,
  3.                                                   const QWidget *widget) const

January 4, 2012

BlackJack BlackJack
Lab Rat
22 posts

it turns out that what that is processed by rendering elements of the application, but not items that are on the main widget, the widget belongs at the application
If any ideas?

Page  
1

  ‹‹ configuring QtSDk on Windows 7      Qpushbutton draws OpenGL problem ››

You must log in to post a reply. Not a member yet? Register here!