百川的焦点jquery 回车切换焦点是怎么实现的

本帖子已过去太久远了,不再提供回复功能。3866人阅读
学习实现计算器中,点击一个lineEdit后,再点击数字按钮,可以将数据或符号显示在选定的lineEdit中。
bool eventFilter(QObject *, QEvent *);
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
ui-&setupUi(this);
m_iCalFlag = 0;
m_editFlag = 0;
ui-&firstLineEdit-&installEventFilter(this);
ui-&secondLineEdit-&installEventFilter(this);
ui-&zeroButton-&setFocusPolicy(Qt::NoFocus);
ui-&oneButton-&setFocusPolicy(Qt::NoFocus);
ui-&twoButton-&setFocusPolicy(Qt::NoFocus);
//QWidget::setFocusPolicy(Qt::NoFocus);
//QPushButton::setFocusPolicy(Qt::NoFocus);
//this-&setFocusPolicy(Qt::NoFocus);
/* 判断焦点位置 */
bool MainWindow::eventFilter(QObject *watched, QEvent *event){
if(watched == ui-&firstLineEdit)
if(event-&type() == QEvent::FocusIn)
QPalette p = QPalette();
p.setColor(QPalette::Base, Qt::green);
ui-&firstLineEdit-&setPalette(p);
printf(&get first focusin \r\n&);
m_editFlag = 1;
else if(event-&type() == QEvent::FocusOut)
QPalette p= QPalette();
p.setColor(QPalette::Base, Qt::white);
ui-&firstLineEdit-&setPalette(p);
printf(&get first focusout \r\n&);
m_editFlag = 0;
else if(watched == ui-&secondLineEdit)
if(event-&type() == QEvent::FocusIn)
QPalette p= QPalette();
p.setColor(QPalette::Base, Qt::green);
ui-&secondLineEdit-&setPalette(p);
printf(&get two focusin \r\n&);
m_editFlag = 2;
else if(event-&type() == QEvent::FocusOut)
QPalette p= QPalette();
p.setColor(QPalette::Base, Qt::white);
ui-&secondLineEdit-&setPalette(p);
printf(&get two focusout \r\n&);
m_editFlag = 0;
return QWidget::eventFilter(watched, event);}
单个控件分别设置焦点为无焦点即可。
Qt::TabFocus 0x1the widget accepts focus by tabbing.
Qt::ClickFocus 0x2the widget accepts focus by clicking.
Qt::StrongFocus TabFocus | ClickFocus | 0x8the widget accepts focus by both tabbing and clicking. On OS X this will also be indicate that the widget accepts tab focus when in 'Text/List
focus mode'.
Qt::WheelFocus StrongFocus | 0x4like Qt::StrongFocus plus the widget accepts focus by using the mouse wheel.
Qt::NoFocus 0
the widget does not accept focus.
尝试了所有的pushbotton一个接口禁用,但是失败了。
在ui界面设置属性中直接设置更方便。
选中控件,在右侧属性栏中找到QWidget-&focusPolicy-&选择NoFocus,则此控件不产生焦点。
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:12828次
排名:千里之外
(1)(1)(1)(1)(3)(2)阅读 : 195
有很多人不明白百川理财的模式,就妄加定论,认为百川理财是传销,下面小编从八个方面阐述:一,百川理财币它有自己的公司,可以让会员实地考察,有自己的实体 产业,百川旗下有百川理财、菁地农业、洗车宝宝,酒店等,有自己的网上商城,还有很多线下百川币指定消费点,传销有吗?二,百川理财不会强迫任何一个人来做,都是本着自愿的原则,投资800元,做静态照样每天有收入。传销一般会交纳高额入会费,拉不到人,就没有收入。三,传销是收了你的钱,让你去听一些洗脑式的课程,限制你的人身自 由。百川不会给你洗脑,更不会限制你的自由,该干吗干吗。四,百川投资800元一单,是一个小本创业,大众创业的理财平台,是一种互联网+直销+众筹模式。传销是吗?五,传销会很低调,很隐蔽,东躲西藏。百川不会,各个电视台先后报道百川集团公司,公司懂事长周运煌更是不停的参加全国各种活动。六,百川理财币与许多知名企业对接,例如:百川和阿里巴巴旗下的淘 宝对接,可以用百川币在淘宝消费。传销敢吗?七,百川集团受到政府的大力支持,江西省新余市政府给百川6000余亩地作为农业基地。传销会得到政府的支持吗?八,百川世界集团不断的在做慈善,捐赠物资。传销有吗?投资800元年入百万,你想要嘛?乞丐和富翁你喜欢跟谁在一起?喜欢正能量可扫一扫添加我们了解更多资讯请扫一扫关注我们
本文来源于微信公众号,如有侵权,请与我们联系。
转载请说明出处()。
微信扫一扫
分享文章到朋友圈jquery实现多屏多图焦点图切换特效的方法
投稿:shichen2014
字体:[ ] 类型:转载 时间:
这篇文章主要介绍了jquery实现多屏多图焦点图切换特效的方法,涉及jQuery插件jquery.kinMaxShow实现焦点图的相关技巧,非常具有实用价值,需要的朋友可以参考下
本文实例讲述了jquery实现多屏多图焦点图切换特效的方法。分享给大家供大家参考。具体实现方法如下:
&!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&
&html xmlns="http://www.w3.org/1999/xhtml"&
&meta http-equiv="Content-Type" content="text/ charset=utf-8"/&
&title&kinMaxShow 技巧效果&/title&
&link type="text/css" href="_doc/base.css" rel="stylesheet"/&
&style type="text/css"&
body{ margin:0; padding:50px 0 0 0;}
#show{width:600 margin:0}
#kinMaxShow{width:600 height:300
visibility: overflow:
#kinMaxShow p.title{
position: left:0; bottom:0;
text-indent:10 line-height:30
font-family:V color:#FFF; display:
width:100%; height:30 font-family:14
filter:progid:DXImageTransform.Microsoft.gradient(
startcolorstr=#aa000000,endcolorstr=#aa000000);
background:rgba(0,0,0,0.5);
&script src="js/jquery-1.10.2.min.js" type="text/javascript"&&/script&
&script src="js/jquery.kinMaxShow-1.1.min.js"
type="text/javascript"&&/script&
&script type="text/javascript"&
$(function(){
$("#kinMaxShow").kinMaxShow({
height:300,
showIndex:true,
normal:{width:'18px',height:'18px',lineHeight:'18px',
right:'16px',bottom:'6px',fontSize:'12px',opacity:0.8,
background:"#666666",border:"1px solid #999999",
color:"#CCCCCC",marginRight:'6px'
background:"#CC0000",border:"1px solid #FF0000",
color:"#000000"
&div id="show"&
&div id="kinMaxShow"&
&a href="#" target="_blank"&
&img src="images/demo_artifice_images/1.jpg" /&&/a&
&p class="title"&新闻111&/p&
&a href="#" target="_blank"&
&img src="images/demo_artifice_images/2.jpg" /&&/a&
&p class="title"&新闻222&/p&
&a href="#" target="_blank"&
&img src="images/demo_artifice_images/3.jpg" /&&/a&
&p class="title"&新闻333&/p&
&a href="#" target="_blank"&
&img src="images/demo_artifice_images/4.jpg" /&&/a&
&p class="title"&新闻444&/p&
&a href="#" target="_blank"&
&img src="images/demo_artifice_images/5.jpg" /&&/a&
&p class="title"&新闻555&/p&
&a href="#" target="_blank"&
&img src="images/demo_artifice_images/6.jpg" /&&/a&
&p class="title"&新闻666&/p&
jquery.kinMaxShow-1.1.min.js点击此处。
希望本文所述对大家的jQuery程序设计有所帮助。
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具&&&&& 这次的项目中有个界面大概需要实现这样的一个功能:当我按键盘Tab键时,焦点在pushButton、pushButton_5、pushButton_9之间切换,当焦点停在pushButton、pushButton_5、pushButton_9之间某个按键时,此时按键盘的向下键焦点在其下方的按键来回切换,例如现在焦点在pushButton_5,我按向下键时,焦点会在pushButton_6、pushButton_7、pushButton_8之间来回切换。有点绕啊!
&&& 可是我现在写得代码能够实现:当焦点在pushButton时,按向下键时,能够在pushButton_2、pushButton_3、pushButton_4之间切换。按Tab键,能实现焦点在pushButton、pushButton_5、pushButton_9之间来回切换,但是当焦点在pushButton_5时,按向下键焦点会在所有的按键当中来回切换,当回到pushButton时,又只能在pushButton_2、pushButton_3、pushButton_4之间切换了。
&&&&& 真是奇了怪了,能在其中的几个按钮之间实现功能,按照同样的方式居然不能达到预期的效果,真是整了一整天没搞出来,有点小郁闷啊
&&&& 下面的代码是我为了实现所需功能的代码,希望那位大神帮我看看,找出问题所在。
widget.h#ifndef WIDGET_H
#define WIDGET_H
#include &QWidget&
namespace Ui {
class Widget : public QWidget
explicit Widget(QWidget *parent = 0);
~Widget();
public slots:
bool eventFilter(QObject *,QEvent *);
//声明一个事件过滤槽函数,用于事件的
Ui::Widget *
#endif // WIDGET_H
&/pre&&pre class=&html& name=&code&&#include &widget.h&
#include &ui_widget.h&
#include &QPushButton&
#include &QKeyEvent&
#include &QPalette&
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
ui-&setupUi(this);
ui-&pushButton-&installEventFilter(this);
//在窗体上为lineEdit1安装过滤器
ui-&pushButton_2-&installEventFilter(this);
//在窗体上为lineEdit1安装过滤器
ui-&pushButton_3-&installEventFilter(this);
//在窗体上为lineEdit1安装过滤器
ui-&pushButton_4-&installEventFilter(this);
//在窗体上为lineEdit1安装过滤器
ui-&pushButton_5-&installEventFilter(this);
//在窗体上为lineEdit1安装过滤器
ui-&pushButton_6-&installEventFilter(this);
//在窗体上为lineEdit1安装过滤器
ui-&pushButton_7-&installEventFilter(this);
//在窗体上为lineEdit1安装过滤器
ui-&pushButton_8-&installEventFilter(this);
//在窗体上为lineEdit1安装过滤器
ui-&pushButton_9-&installEventFilter(this);
//在窗体上为lineEdit1安装过滤器
ui-&pushButton_10-&installEventFilter(this);
//在窗体上为lineEdit1安装过滤器
ui-&pushButton_11-&installEventFilter(this);
//在窗体上为lineEdit1安装过滤器
ui-&pushButton_12-&installEventFilter(this);
//在窗体上为lineEdit1安装过滤器
Widget::~Widget()
bool Widget::eventFilter(QObject *watched, QEvent *event)
watched==ui-&pushButton||
watched==ui-&pushButton_2||
watched==ui-&pushButton_3||
watched==ui-&pushButton_4||
watched==ui-&pushButton_5||
watched==ui-&pushButton_6||
watched==ui-&pushButton_7||
watched==ui-&pushButton_8||
watched==ui-&pushButton_9||
watched==ui-&pushButton_10||
watched==ui-&pushButton_11||
watched==ui-&pushButton_12
if(event-&type()==QEvent::KeyPress)
QKeyEvent *key_event = static_cast & QKeyEvent *&(event); //将事件转化为键盘事件
if(key_event-&key() == Qt::Key_Tab)//下键
pushButton =ui-&pushButton-&hasFocus();
pushButton_5 =ui-&pushButton_5-&hasFocus();
pushButton_9 =ui-&pushButton_9-&hasFocus();
if( pushButton)//焦点在pushButton处
focusNextChild();//焦点移动
ui-&pushButton_5-&setFocus();//移动到apushButton_2
else if(pushButton_5)//焦点在apushButton_5处
focusNextChild();//焦点移动
ui-&pushButton_9-&setFocus();//移动到pushButton_3
else if(pushButton_9)//焦点在pushButton_9处
focusNextChild();//焦点移动
ui-&pushButton-&setFocus();//移动到pushButton_4
focusNextChild();//焦点移动
if(key_event-&key() == Qt::Key_Down)//下键
pushButton =ui-&pushButton-&hasFocus();
pushButton_2 =ui-&pushButton_2-&hasFocus();
pushButton_3 =ui-&pushButton_3-&hasFocus();
pushButton_4 =ui-&pushButton_4-&hasFocus();//定义4个获得焦点的状态
if(pushButton)//焦点在pushButton处
focusNextChild();//焦点移动
ui-&pushButton_2-&setFocus();//移动到apushButton_2
else if(pushButton_2)//焦点在apushButton_2处
focusNextChild();//焦点移动
ui-&pushButton_3-&setFocus();//移动到pushButton_3
else if(pushButton_3)//焦点在pushButton_3处
focusNextChild();//焦点移动
ui-&pushButton_4-&setFocus();//移动到pushButton_4
else if(pushButton_4)//焦点在pushButton_3处
focusNextChild();//焦点移动
ui-&pushButton_2-&setFocus();//移动到pushButton_2
focusNextChild();//焦点移动
if(key_event-&key() == Qt::Key_Down)//下键
pushButton_5 =ui-&pushButton_5-&hasFocus();
pushButton_6 =ui-&pushButton_6-&hasFocus();
pushButton_7 =ui-&pushButton_7-&hasFocus();
pushButton_8 =ui-&pushButton_8-&hasFocus();//定义4个获得焦点的状态
if(pushButton_5)//焦点在pushButton处
focusNextChild();//焦点移动
ui-&pushButton_6-&setFocus();//移动到apushButton_2
else if(pushButton_6)//焦点在apushButton_6处
focusNextChild();//焦点移动
ui-&pushButton_7-&setFocus();//移动到pushButton_3
else if(pushButton_7)//焦点在pushButton_7处
focusNextChild();//焦点移动
ui-&pushButton_8-&setFocus();//移动到pushButton_4
else if(pushButton_8)//焦点在pushButton_8处
focusNextChild();//焦点移动
ui-&pushButton_7-&setFocus();//移动到pushButton_2
focusNextChild();//焦点移动
if(key_event-&key() == Qt::Key_Left)//下键
pushButton_9 =ui-&pushButton_9-&hasFocus();
pushButton_10 =ui-&pushButton_10-&hasFocus();
pushButton_11 =ui-&pushButton_11-&hasFocus();
pushButton_12 =ui-&pushButton_12-&hasFocus();//定义4个获得焦点的状态
if(pushButton_9)//焦点在pushButton处
focusNextChild();//焦点移动
ui-&pushButton_10-&setFocus();//移动到apushButton_2
else if(pushButton_10)//焦点在apushButton_10处
focusNextChild();//焦点移动
ui-&pushButton_11-&setFocus();//移动到pushButton_3
else if(pushButton_11)//焦点在pushButton_11处
focusNextChild();//焦点移动
ui-&pushButton_12-&setFocus();//移动到pushButton_4
else if(pushButton_12)//焦点在pushButton_12处
focusNextChild();//焦点移动
ui-&pushButton_10-&setFocus();//移动到pushButton_2
focusNextChild();//焦点移动
return QWidget::eventFilter(watched,event);
// 最后将事件交给上层对话框
&&& 上面就是整个代码了,其中main.cpp没有改动,所以就没贴上来。
&&&&&代码编译完全没有错误,但是不能实现预期的功能,感觉是逻辑上的问题,但是检查几遍都没检查出啥情况,Qt界的大神们给我看看吧,感激不尽
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:3257次
排名:千里之外

我要回帖

更多关于 win7自动切换窗口焦点 的文章

 

随机推荐