Results 1 to 3 of 3

Thread: image for a custom menu Item.......

  1. #1

    Question image for a custom menu Item.......

    Look at the code below......
    I'm adding an item to the contextMenu like this.....where restore1() is a custom method.....

    QMenu menu(this);
    QAction *restore = menu.addAction(tr("&restore"));
    restore->setShortcut(Qt::CTRL | Qt::Key_R);
    connect(restore,SIGNAL(triggered()),this,SLOT(rest ore1()));

    Until here its working fine but .....now i would like to add an Image before the context menu item (restore in this case.....) and not only that ......I want make the display of custom menu item(which is restore here) look BOLD...........

  2. #2
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: image for a custom menu Item.......

    In qt3 examples available example menu which answer on your questions
    a life without programming is like an empty bottle

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: image for a custom menu Item.......

    Icon and font are properties of QAction:

    Icon:
    http://doc.trolltech.com/4.1/qaction.html#icon-prop
    Qt Code:
    1. restore->setIcon(QIcon("restore.png"));
    To copy to clipboard, switch view to plain text mode 

    Font:
    http://doc.trolltech.com/4.1/qaction.html#font-prop
    Qt Code:
    1. QFont font = restore->font();
    2. font.setBold(true);
    3. restore->setFont(font);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. creating a "path" for the menu item
    By roxton in forum Qt Programming
    Replies: 4
    Last Post: 17th January 2009, 16:32
  2. Menu Item has no highlight
    By blackfox in forum Qt Programming
    Replies: 6
    Last Post: 24th September 2008, 12:17
  3. list of custom item views?
    By Beluvius in forum Qt Programming
    Replies: 1
    Last Post: 29th March 2008, 06:43
  4. Background image on popup menu item
    By MarkoSan in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 27th June 2006, 05:55
  5. Qt/MacOSX preferences menu item
    By mcenatie in forum Qt Programming
    Replies: 4
    Last Post: 14th March 2006, 04:24

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.