Change trinagle in the menu button
-
wrote on 29 Dec 2011, 12:22 last edited by
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?
-
wrote on 29 Dec 2011, 12:26 last edited by
you mean a tool tip ? You could post here a screen shot too..
-
wrote on 29 Dec 2011, 12:37 last edited by
!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 )@ -
wrote on 29 Dec 2011, 13:05 last edited by
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.
-
wrote on 29 Dec 2011, 14:24 last edited by
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.
-
wrote on 29 Dec 2011, 15:16 last edited by
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
-
wrote on 29 Dec 2011, 18:52 last edited by
[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()]] -
wrote on 29 Dec 2011, 18:56 last edited by
I think he means "standardIconImplementation":http://developer.qt.nokia.com/doc/qt-4.8/qstyle.html#standardIconImplementation
-
wrote on 30 Dec 2011, 08:37 last edited by
Yeah, sorry, that's what I mend.
-
wrote on 30 Dec 2011, 11:52 last edited by
Hello
I have a similar problem.
You need to replace the standard icon, on the otherI 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);}
@ -
wrote on 4 Jan 2012, 09:54 last edited by
that no one will help me not? :(
-
wrote on 4 Jan 2012, 10:07 last edited by
Is your method actually called? Are you sure your proxy style is used as the style for the application?
-
wrote on 4 Jan 2012, 10:13 last edited by
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();
}@
-
wrote on 4 Jan 2012, 10:15 last edited by
Are you sure as in: you inserted some debug statement in your QProxyStyle-derived class and you actually get the debug output?
-
wrote on 4 Jan 2012, 10:24 last edited by
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@ -
wrote on 4 Jan 2012, 12:22 last edited by
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? -
wrote on 4 Jan 2012, 12:23 last edited by
I have no idea what you mean by your last question. Sorry. Please try to reformulate.
-
wrote on 5 Jan 2012, 08:13 last edited by
have any idea why the realties do not want to handle the painting elements widgit ?
-
wrote on 5 Jan 2012, 08:24 last edited by
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
-
wrote on 5 Jan 2012, 08:55 last edited by
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: "";
}
@
3/20