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
您需要创建HorizontalToolbar
类的实例。
m_horizontalMapToolbar = std::make_shared<HorizontalToolbar>();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.