Getting copy (CTRL + C) to work in abstractnavigationwidget (context browser tooltips)

Milian Wolff mail at milianw.de
Thu Sep 23 19:52:49 UTC 2010


Heyho,

me again... I'm desperately trying to get copy to work in 
AbstractNavigationWidgets's. I can't get it to work, no matter what approach I 
try.

I tried the obvious:

m_browser->addAction( KStandardActions::copy(m_browser) );

I tried the less obvious:

~~~
class Browser : public KTextBrowser {
  Q_OBJECT

public:
  explicit Browser( QWidget* parent = 0, bool notifyClick = false )
    : KTextBrowser(parent, notifyClick)
  {
  }
protected:
  virtual void keyPressEvent( QKeyEvent* event )
  {
    qDebug() << "browser key press event:" << event->key() << event-
>modifiers();
    if (event->key() == Qt::Key_C && event->modifiers() == Qt::ControlModifier) 
{
      qDebug() << "copy yeah yeah yeah" << textCursor().selectedText();
      copy();
      event->accept();
      return;
    }
  }

};
...
m_browser = new Browser;
~~~

I even tried an eventFilter or put the stuff into AbstractNavigationWidget's 
keyPress overload - all to no avail... No I have to forfeit and ask for your 
input...

What I noticed is that the tooltip closes when I release *any* key, e.g.: Make 
a tooltip showup, press and release just a modifier key like CTRL => tooltip is 
hidden. May that be the reason (where is that eventFilter to do the hide in 
this case btw?)? But shouldn't keyPress(QKeyEvent* e) be called *before* the 
key release? Why don't I even get this?

Help!


-- 
Milian Wolff
mail at milianw.de
http://milianw.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20100923/21f7731e/attachment.sig>


More information about the KDevelop-devel mailing list