Results 1 to 5 of 5

Thread: Problems creating a ToolBar

  1. #1
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    694
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Problems creating a ToolBar

    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
    Franco Amato

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Problems creating a ToolBar

    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...

  3. #3
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    694
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problems creating a ToolBar

    Quote Originally Posted by Lykurg View Post
    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

    Qt Code:
    1. void MainWindow::createToolBar()
    2. {
    3. exitToolBar = addToolBar(tr("Exit"));
    4. exitToolBar->addAction(exitAct);
    5. }
    To copy to clipboard, switch view to plain text mode 
    and the action

    Qt Code:
    1. /* Exit action */
    2. exitAct = new QAction(QIcon(":/images/exit.png"), tr("E&xit"), this);
    3. exitAct->setShortcut( tr("Ctrl+Q") );
    4. exitAct->setStatusTip(tr("Exit the application"));
    5. connect( exitAct, SIGNAL( triggered() ), this, SLOT( close() ) );
    To copy to clipboard, switch view to plain text mode 

    the qrc file:
    Qt Code:
    1. <RCC>
    2. <qresource>
    3. <file>images/exit.png</file>
    4. </qresource>
    5. </RCC>
    To copy to clipboard, switch view to plain text mode 

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

  4. #4
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    694
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problems creating a ToolBar - SOLVED

    Quote Originally Posted by franco.amato View Post
    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

    Qt Code:
    1. void MainWindow::createToolBar()
    2. {
    3. exitToolBar = addToolBar(tr("Exit"));
    4. exitToolBar->addAction(exitAct);
    5. }
    To copy to clipboard, switch view to plain text mode 
    and the action

    Qt Code:
    1. /* Exit action */
    2. exitAct = new QAction(QIcon(":/images/exit.png"), tr("E&xit"), this);
    3. exitAct->setShortcut( tr("Ctrl+Q") );
    4. exitAct->setStatusTip(tr("Exit the application"));
    5. connect( exitAct, SIGNAL( triggered() ), this, SLOT( close() ) );
    To copy to clipboard, switch view to plain text mode 

    the qrc file:
    Qt Code:
    1. <RCC>
    2. <qresource>
    3. <file>images/exit.png</file>
    4. </qresource>
    5. </RCC>
    To copy to clipboard, switch view to plain text mode 

    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
    Franco Amato

  5. #5
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Problems creating a ToolBar - SOLVED

    Quote Originally Posted by franco.amato View Post
    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.

Similar Threads

  1. Check box creating problems
    By mat_me in forum Newbie
    Replies: 1
    Last Post: 1st May 2009, 09:20
  2. Problems creating a Slider
    By franco.amato in forum Qt Programming
    Replies: 3
    Last Post: 30th September 2008, 21:33
  3. problems creating toolbar...(do see the attachment)!
    By sumit in forum Qt Programming
    Replies: 15
    Last Post: 10th September 2008, 11:23
  4. Toolbar
    By assismvla in forum Qt Programming
    Replies: 1
    Last Post: 17th July 2008, 17:42
  5. Palette toolbar
    By Radagast in forum Qt Programming
    Replies: 8
    Last Post: 7th July 2008, 17:56

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.