G
G
gense2018-07-01 10:53:06
Qt
gense, 2018-07-01 10:53:06

Why doesn't QToolBar::addWidget() work?

I create a new Qt Designer form class, throw a couple of buttons on the form so that it is, define its instance in the main window class:

MyToolbarWidget *myToolBarWidget; // MyToolBarWidget наследуется от QWidget
QAction *myToolBarWidgetAction; // может манипуляции через setVisible() помогут? (спойлер: нет)

I'm trying to create the instance object itself in the main window constructor and add it via addWidget to the toolbar:
myToolBarWidget = new MyToolBarWidget(ui->toolBar); 
myToolBarWidgetAction = ui->toolBar->addWidget(myToolBarWidget);

But after compilation and launch, the toolbar remains empty as it was.
None of them help. Creating a button programmatically (without a designer) does not solve anything either. Any ideas why it doesn't work? There is nothing in the documentation about this, even there are no examples (or I did not find xs).
myToolBarWidgetAction->setVisible(true);

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question