Preface: I'm relatively new to C++ and coding in general, so my jargon and understanding of specific terminology is on the weaker side.

I'm having difficulty with understanding the proper syntax and functionality of filling a copy slot with the desired information. Basically my knowledge of Signals and Slots is not the best.

So, I'm working on an established app interface with tooltips in place that appear when hovering over an icon. I would like to create a right click event that would copy the tooltip message to the clipboard.

So far I have a contextMenuEvent() that has only a copy option and it properly appears when I right click on the icon. But where I get lost is, what do I have to input in the copy action to copy the tool tip message message itself?

Qt Code:
  1. void
  2. SomeClass::SomeLabel::mouseMoveEvent( QMouseEvent *event )
  3. {
  4. Q_UNUSED( event );
  5.  
  6. // Show tooltip at a particular place of the icon, no matter where
  7. // the mouse comes into the icon
  8.  
  9. QToolTip::showText( this->mapToGlobal( QPoint( this->minimumSize().width()/2, this->minimumSize().height()/2 ) ), this->toolTip(), this, this->rect() );
  10.  
  11. QLabel::mouseMoveEvent( event );
  12.  
  13. return;
  14. }
  15.  
  16.  
  17. // virtual
  18. void
  19. SomeClass::SomeLabel::contextMenuEvent( QContextMenuEvent *event )
  20. {
  21.  
  22. QMenu menu;
  23. menu.addAction( m_copyInvalidityMessage );
  24.  
  25. menu.exec( event->globalPos() );
  26.  
  27. return;
  28. }
  29.  
  30. void
  31. SomeClass::SomeLabel::copyInvalidityMessageAction( void )
  32. {
  33.  
  34. m_copyInvalidityMessage = new QAction( QIcon( ":/application/Copy.ico" ), tr( "Copy Message" ), this );
  35. connect( m_copyInvalidityMessage, SIGNAL( triggered( void ) ), this, SLOT( copyInvalidityTriggered( void ) ) );
  36.  
  37. return;
  38. }
  39.  
  40. void
  41. SomeClass::SomeLabel::copyInvalidityTriggered(void)
  42. {
  43. QApplication::clipboard()->setText( text() );
  44.  
  45. return;
  46. }
To copy to clipboard, switch view to plain text mode 

My guess, which isn't a good guess at all, is that in copyInvalidityTriggered(void) the setText(text()) needs something? Any help or direction to documentation that may explain or show examples would be greatly appreciated. Thank you.