[Qt-interest] special trick needed to get toolbars to show up?
kent williams
nkwmailinglists at gmail.com
Thu Oct 21 18:33:56 CEST 2010
I have this code in my main application window class (derived from QMainWindow):
QToolBar *toolbar(this->addToolBar(tr("View")));
// add icons for different views.
static struct { const char *filename; const char *description;
const char *action;
} toolBarItems[] = {
{ ":/images/axialicon.jpg", "Axial View", SLOT(axialview()) },
{ ":/images/coronalicon.jpg", "Coronal View", SLOT(coronalview()) },
{ ":/images/sagittalicon.jpg", "Sagittal view", SLOT(sagittalview()) },
{ ":/images/3dicon.jpg", "3D View", SLOT(_3dview()) },
{ ":/images/4dicon.jpg", "4-way View", SLOT(_4dview()) },
{ 0, 0 },
};
for (unsigned i = 0; toolBarItems[i].filename != 0; i++)
{
this->m_ToolBarIcons[i] = new QIcon(toolBarItems[i].filename);
QAction *curAction = toolbar->addAction(*(this->m_ToolBarIcons[i]),
tr(toolBarItems[i].description));
connect(curAction, SIGNAL(triggered()), this, toolBarItems[i].action);
}
I do my initial development using OS X. I'd never gotten my icons to
show up on the toolbar in OS X and figured I was doing something
wrong. I tabled this problem while I attacked higher-priority tasks.
Last week, I got around to building my application on Linux, and on
Linux, the buttons show up and work properly.
Does adding toolbars to a QMainWindow-derived class just not work on
OS X, or is there some sort of special dance step it takes to make it
work?
More information about the Qt-interest-old
mailing list