How can I add space before QAction
icons.Like this image.I set style-sheet for mainToolBar
like this spacing:10px;
But I need to add tab space before icon 1.
Asked
Active
Viewed 924 times
2

Sachith Wickramaarachchi
- 5,546
- 6
- 39
- 68
1 Answers
2
Make placeholder widget and use QToolBar::insertWidget for insert that widget. UPD: Example of code
QWidget* placeholder = new QWidget( this );
ui->toolBar->insertWidget( new QAction( this ), placeholder );
placeholder->setWidth(100);

stanislav888
- 374
- 2
- 9
-
I'm not clear your answer.can you please tell me how can I do it.can you give me a sample – Sachith Wickramaarachchi Dec 18 '17 at 11:30
-
{ QWidget* placeholder = new QWidget( this ); ui->toolBar->insertWidget( new QAction( this ), placeholder ); placeholder->setWidth(100); } – stanislav888 Dec 18 '17 at 12:06
-
Just remove extra 's' in method name. Right name is 'QToolBar::addAction' – stanislav888 Dec 18 '17 at 13:45
-
`setWidth()` is not member of `QWidget` .. use `placeholder->setMinimumWidth(100);` – Mohammad Kanan Aug 18 '19 at 15:53