I have to create a drop down with only image applied to it. Similar to the one shown below
DropDown.jpg
I'm using QToolButton to achieve this using the following code
m_pPrimitiveToolBar = addToolBar(tr("Primitives"));
m_pPrimitiveToolButton
= new QToolButton(m_pPrimitiveToolBar
);
m_pPrimitiveToolButton->setGeometry(8, 1, 120, 30);
m_pSphereToolAction
= new QAction(QIcon("Resources/UI/icons/Sphere.png"),tr
(""),
this);
m_pSphereToolAction->setStatusTip(tr("Create Sphere"));
m_pCubeToolAction
= new QAction(QIcon("Resources/UI/icons/Cube.png"), tr
(""),
this);
m_pCubeToolAction->setStatusTip(tr("Create Cube"));
m_pPrimitiveToolButton
->setPopupMode
(QToolButton::MenuButtonPopup);
m_pPrimitiveToolButton->addAction(m_pSphereToolAction);
m_pPrimitiveToolButton->addAction(m_pCubeToolAction);
m_pPrimitiveToolBar = addToolBar(tr("Primitives"));
m_pPrimitiveToolButton = new QToolButton(m_pPrimitiveToolBar);
m_pPrimitiveToolButton->setGeometry(8, 1, 120, 30);
m_pSphereToolAction = new QAction(QIcon("Resources/UI/icons/Sphere.png"),tr(""), this);
m_pSphereToolAction->setStatusTip(tr("Create Sphere"));
m_pCubeToolAction = new QAction(QIcon("Resources/UI/icons/Cube.png"), tr(""), this);
m_pCubeToolAction->setStatusTip(tr("Create Cube"));
m_pPrimitiveToolButton->setPopupMode(QToolButton::MenuButtonPopup);
m_pPrimitiveToolButton->addAction(m_pSphereToolAction);
m_pPrimitiveToolButton->addAction(m_pCubeToolAction);
To copy to clipboard, switch view to plain text mode
I'm getting the following output
CustomDropDown.jpg
Please suggest me the correct way to achieve this.
Bookmarks