Reputation: 4607
I have added a new designer form class to my project that is a widget. Using designer i have added some buttons and labels etc to the widget (which i want to use as my toolbar).
The .cpp and .h files for the widget are untouched and basically just as they are when a new widget is created in qt.
i have a different form that i have added a QToolbar to and now i want to add my widegt to that tool bar
i added this code to my constructor of the form i want the toolbar on, m_horizontalToolBar was declared in the header like this std::shared_ptr<HorizontalToolbar> m_horizontalToolbar;
QToolBar *tool = new QToolBar;
tool->addWidget(m_horizontalMapToolbar.get());
this->addToolBar(tool);
this compiles and runs but nothing displays in the toolbar
I have had a look at this question
The person seems to have got it working but it doesnt really say how at all
seeing as how tool bar has an "addWidget" function i assume this is possible, any light on this would be helpful
Upvotes: 1
Views: 751
Reputation: 12931
You need to create an instance of your HorizontalToolbar
class.
m_horizontalMapToolbar = std::make_shared<HorizontalToolbar>();
Upvotes: 1