PDA

View Full Version : Problems creating a ToolBar



franco.amato
22nd February 2010, 20:44
Hi I would create a toolbar with icons and I can't.
I understood that I have to create a *.qrc file. I use visual studio and when I click on the .qrc file created a
Qtt qrc editor starts but I'm unable to use it. The is a "prefix" field. What is it?
The final result is that I can not create the toolbar.

I hope to get help.
Best Regards,
Franco

Lykurg
22nd February 2010, 22:06
Come on Franco! How long are you dealing with Qt now? I am sure you noticed the assistant, please use it: http://doc.trolltech.com/4.6/resources.html. And your prefix question will solve, when you read that. About the toolbar one can hardly say something if you don't show the code you are using. And there is no direct connection between images and toolbars...

franco.amato
23rd February 2010, 15:31
Come on Franco! How long are you dealing with Qt now? I am sure you noticed the assistant, please use it: http://doc.trolltech.com/4.6/resources.html. And your prefix question will solve, when you read that. About the toolbar one can hardly say something if you don't show the code you are using. And there is no direct connection between images and toolbars...

Which code do you need? I exactly copied from the mainwindow example.
I get the icon in the menu but the toolbar is not created



void MainWindow::createToolBar()
{
exitToolBar = addToolBar(tr("Exit"));
exitToolBar->addAction(exitAct);
}

and the action


/* Exit action */
exitAct = new QAction(QIcon(":/images/exit.png"), tr("E&xit"), this);
exitAct->setShortcut( tr("Ctrl+Q") );
exitAct->setStatusTip(tr("Exit the application"));
connect( exitAct, SIGNAL( triggered() ), this, SLOT( close() ) );

the qrc file:

<RCC>
<qresource>
<file>images/exit.png</file>
</qresource>
</RCC>

I don't understand why the toolbar is not created.

franco.amato
23rd February 2010, 18:47
Which code do you need? I exactly copied from the mainwindow example.
I get the icon in the menu but the toolbar is not created



void MainWindow::createToolBar()
{
exitToolBar = addToolBar(tr("Exit"));
exitToolBar->addAction(exitAct);
}

and the action


/* Exit action */
exitAct = new QAction(QIcon(":/images/exit.png"), tr("E&xit"), this);
exitAct->setShortcut( tr("Ctrl+Q") );
exitAct->setStatusTip(tr("Exit the application"));
connect( exitAct, SIGNAL( triggered() ), this, SLOT( close() ) );

the qrc file:

<RCC>
<qresource>
<file>images/exit.png</file>
</qresource>
</RCC>

I don't understand why the toolbar is not created.

I solved the problem,
but now I would know if Qt support 48 x 48 icons in the toolbar because seems that only support 32 x 32.
Best Regards

Lykurg
23rd February 2010, 18:56
but now I would know if Qt support 48 x 48 icons in the toolbar because seems that only support 32 x 32.
The size is handled by your application style. See QStyle::PM_ToolBarIconSize. You can try to alter the size there or you can try use a style sheet, but I am not sure if you can change the size there.