开发第一个helloworld插件,右键不能弹出菜单
Tofloor
poster avatar
easezhi
deepin
2017-04-12 17:34
Author
论坛demo里的插件图标m_icon,用QLabel类,渲染了一个图片。我参照这个demo手敲代码,因为不清楚怎么渲染图片,就只给这个QLabel设置了文字。itemContextMenu和invokedMenuItem都已经重写了。安装的时候,只是简单的cp那个so文件到plugins目录。现在dock上能出来插件,图标就是文字“hello”,鼠标放上去也能出现提示文字。但是右键点击的时候,没有出来插件的菜单,出来的是dock的菜单。
这个问题是跟这个QLabel只设置文字有关吗?
还有,论坛的demo我编译之后,只复制so文件,插件没有生效。是不是需要用make install来安装呀?我对make不熟悉,不知道make install的时候,操作了哪些文件。

Reply Favorite View the author
All Replies
avatar
emofode
deepin
2017-04-12 17:58
#1
发代码看看?
Reply View the author
avatar
easezhi
deepin
2017-04-12 18:23
#2
  1. HelloWorldPlugin::HelloWorldPlugin() :
  2.     QObject(nullptr),
  3.     //m_icon(new QLabel),
  4.     m_icon(new QLabel("hello")),
  5.     m_tooltip(new QLabel("Hello World"))
  6. {
  7.     //QPixmap pix(":/deepin.png");
  8.     //m_icon->setPixmap(pix);
  9.     //m_icon->setMargin(6);
  10.     //m_icon->setAlignment(Qt::AlignCenter);
  11.     //m_icon->setScaledContents(true);
  12.    
  13.     m_tooltip->setStyleSheet("color:white."
  14.                             "padding:5px 10px.");
  15. }
Copy the Code

注掉了处理图片的代码,m_icon初始化的时候,加了字符串参数
Reply View the author
avatar
easezhi
deepin
2017-04-13 01:36
#3

能看出来什么问题吗/(ㄒoㄒ)/~~
Reply View the author
avatar
easezhi
deepin
2017-04-13 03:44
#4
https://bbs.deepin.org/post/137500
就一个构造函数,能看出问题那就真的是神人了。

easy,easy!看不出来,我自己慢慢调。
Reply View the author
avatar
j***e@163.com
deepin
2017-04-13 04:15
#5
仰望大神们吹水
Reply View the author
avatar
easezhi
deepin
2017-04-13 06:13
#6
已经解决了。QLabel没有向插件注册事件监听。第一次写的时候不知道那两个函数的用途,就没有copy过来。
Reply View the author
avatar
sudo_free
deepin
2017-04-13 07:16
#7
https://bbs.deepin.org/post/137500
easy,easy!看不出来,我自己慢慢调。

你可以看下他的github参考

当然工程结构可以看看官方的:https://github.com/linuxdeepin/dde-dock/tree/master/plugins

Reply View the author