PDA

View Full Version : QAction and setText



babu198649
4th February 2009, 05:49
Hi
I want to add an QAction to toolbar which contains only text(no Icons).The text will contain spaces but the spaces are stripped down even when i used the QAction::setText(const QString& text) function.
In the following code the space's are stripped downl

QAction *ac=new QAction(this);
ac->setText(" act ");//the spaces are stripped down
addToolBar("toolbar")->addAction(ac);

How to get the spaces in QAction text.

jpn
4th February 2009, 12:06
The text will contain spaces but the spaces are stripped down even when i used the QAction::setText(const QString& text) function.
Yes, that's intentional.

babu198649
4th February 2009, 13:05
The QAction docs says,


The action uses a stripped version of text (e.g. "&Menu Option..." becomes "Menu Option") as descriptive text for tool buttons. You can override this by setting a specific description with setText().
How to get the space in the QAction text

jpn
4th February 2009, 14:32
QToolButton* button = new QToolButton(this);
button->setText(" act ");
addToolBar("toolbar")->addWidget(button);