Change trinagle in the menu button



  • 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?



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



  • !http://developer.qt.nokia.com/doc/qt-4.8/images/cleanlooks-pushbutton-menu.png(Menu button)!

    You can see it the documentation for QPushButton
    @void QPushButton::setMenu ( QMenu * menu )@



  • 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.



  • 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.



  • You could try creating a [[doc: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



  • [quote author="Andre" date="1325171799"]You could try creating a [[doc:QProxyStyle]] and reimplementing QStyle::standardItemImplementation() [/quote]
    Interesting idea, but I don't found [[doc:QStyle::standardItemImplementation()]]





  • Yeah, sorry, that's what I mend.



  • 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...

    @class CustomStyle :
    public QProxyStyle
    {
    Q_OBJECT
    public:
    CustomStyle();

    protected slots:
    QIcon standardIconImplementation(StandardPixmap standardIcon,
    const QStyleOption *option,
    const QWidget *widget) const;
    };
    @
    and the implementation itself
    @QIcon CustomStyle::standardIconImplementation(StandardPixmap standardIcon,
    const QStyleOption *option,
    const QWidget *widget) const
    {
    switch(standardIcon)
    {
    case QStyle::SP_TitleBarMenuButton:
    return QIcon(":/image/circle_middle.png");
    case QStyle::SP_ArrowDown:
    return QIcon(":/image/circle_middle.png");
    case QStyle::SP_CommandLink:
    return QIcon(":/image/circle_middle.png");
    }
    return QProxyStyle::standardIconImplementation(standardIcon, option, widget);

    }
    @



  • that no one will help me not? :(



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



  • Yes it is connected and is the default style
    @#include "customstyle.h"
    #include "widget.h"

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);

    a.setStyle(new CustomStyle());
    
    Widget w;   w.show();
    
    return a.exec();
    

    }@



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



  • 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

    @QIcon CustomStyle::standardIconImplementation(StandardPixmap standardIcon,
    const QStyleOption *option,
    const QWidget *widget) const@



  • 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?



  • I have no idea what you mean by your last question. Sorry. Please try to reformulate.



  • have any idea why the realties do not want to handle the painting elements widgit ?



  • sorry, it's probably my bad english (

    I will try to reformulate.

    When run the program in the debugger and do a breakpoint in my overriding function

    @
    QIcon CustomStyle::standardIconImplementation(StandardPixmap standardIcon,
    const QStyleOption *option,
    const QWidget *widget) const--
    @

    function comes in only 2 times though Widgit is all sorts of different elements of the table, buttons, and just from the drop-down lists on PushButton with which the problem's



  • problem can be solved much more than I ask all thought to remove the triangle can be with the aid of styles

    @
    QPushButton:: menu-indicator {
    image: "";
    }
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.