Results 1 to 2 of 2

Thread: Context Menu in Qt

  1. #1
    Join Date
    Mar 2014
    Posts
    15
    Thanks
    1
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Context Menu in Qt

    Hi, i have created a context menu. But when i am hovering mouse over its item, the color of item becomes same as color of background and nothing is displayed.
    Please help.

    Here is my code:
    Qt Code:
    1. m_TestViewQTreeView=new QTreeView();
    2.  
    3. m_TestViewQTreeView->setContextMenuPolicy(Qt::ActionsContextMenu);
    4.  
    5. QMenu *menu=new QMenu();
    6. menu->setStyleSheet("QMenu{background-color:red}");
    7.  
    8. QAction *run=new QAction(QIcon(":/Resources/TCstart.png"),"Run",menu);
    9. connect(run,SIGNAL(triggered()),this,SLOT(Run_Click()));
    10.  
    11.  
    12.  
    13. m_TestViewQTreeView->addAction(run);
    To copy to clipboard, switch view to plain text mode 
    Last edited by anda_skoa; 26th May 2014 at 19:44. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Context Menu in Qt

    I don't think you need to create a QMenu when you are using the ActionsContextMenu policy, QWidget will create one and put all actions into it.

    Have you tried with a different widget style? Maybe the one you are currently using has a bug?

    Cheers,
    _

Similar Threads

  1. Qt Context menu
    By jeyanthinatarajan in forum Newbie
    Replies: 3
    Last Post: 4th April 2012, 23:26
  2. Replies: 1
    Last Post: 4th November 2011, 12:25
  3. Context menu on tab
    By wolfi3b in forum Newbie
    Replies: 2
    Last Post: 18th October 2010, 18:35
  4. Qwt and context menu
    By giusepped in forum Qwt
    Replies: 1
    Last Post: 9th December 2008, 09:55
  5. Context Menu
    By RY in forum Newbie
    Replies: 1
    Last Post: 10th September 2008, 08:59

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.