赞
踩
01 | void ImEffectWidget::slotSlider( int pos) |
02 | { |
03 | static int oldPos = 0; |
04 | if (oldPos != pos) |
05 | { |
06 | QRect r; |
07 | QObject *o = sender(); |
08 | // |
09 | ImSignalBlock block; |
10 | block << m_ui.spinBoxTransparent << m_ui.spinBoxVerticalPos |
11 | << m_ui.spinBoxHerizontalPos << m_ui.spinBoxSTTransparent |
12 | << m_ui.spinBoxSTVPos; |
13 | int tabType = m_treeItem->mdata( "effect_catalog" ).toInt(); |
14 | if (tabType == TAB_CATALOG_WATERMARK ){ |
15 | r = m_treeItem->getEffectItem( "effect_item_rect" ).toRect(); |
16 | } |
17 | |
18 | /* 3. for watermark ***************************/ |
19 | else if (o->objectName() == "sliderTransparent" ){ |
20 | m_ui.spinBoxTransparent->setValue(pos); //与spinbox关联 |
21 | m_treeItem->setEffectItem( "effect_item_transparent" , pos); |
22 | } else if (o->objectName() == "sliderVerticalPos" ){ |
23 | r.moveLeft(pos); |
24 | m_ui.spinBoxVerticalPos->setValue(pos); |
25 | } else if (o->objectName() == "sliderHorizontalPos" ){ |
26 | r.moveTop(pos); |
27 | m_ui.spinBoxHerizontalPos->setValue(pos); |
28 | } |
29 | /* 5. for subtitle ***************************/ |
30 | else if (o->objectName() == "sliderSTTransparent" ){ |
31 | m_ui.spinBoxSTTransparent->setValue(pos); |
32 | m_treeItem->setMediaData( "effect_subtitle_transparent" , pos); |
33 | } else if (o->objectName() == "sliderSTVPos" ){ |
34 | m_ui.spinBoxSTVPos->setValue(pos); |
35 | m_treeItem->setMediaData( "effect_subtitle_pos" , pos); |
36 | } |
37 | |
38 | if (tabType == TAB_CATALOG_WATERMARK ){ |
39 | m_treeItem->setEffectItem( "effect_item_rect" , r); |
40 | } |
41 | sendEffectEvent(); //向sdl发信号 |
42 | oldPos = pos; |
43 | } |
44 | } |
01 | #ifndef IMSIGNALBLOCK_H_ |
02 | #define IMSIGNALBLOCK_H_ |
03 | #include <QObject> |
04 | class ImSignalBlock |
05 | { |
06 | public : |
07 | ImSignalBlock(); |
08 | ~ImSignalBlock(); |
09 | ImSignalBlock &operator<< (QObject *o); |
10 | private : |
11 | QList<QObject*> m_objs; |
12 | }; |
13 | #endif |
14 | ImSignalBlock.cpp: |
15 | #include <QDebug> |
16 | #include "ImSignalBlock.h" |
17 | ImSignalBlock::ImSignalBlock() |
18 | { |
19 | } |
20 | ImSignalBlock::~ImSignalBlock() |
21 | { |
22 | foreach (QObject* o, m_objs) |
23 | { |
24 | if (o) o->blockSignals( false ); |
25 | } |
26 | } |
27 | ImSignalBlock &ImSignalBlock::operator<< (QObject *o) |
28 | { |
29 | if (o) |
30 | { |
31 | m_objs.append(o); |
32 | qDebug() << o->objectName(); |
33 | o->blockSignals( true ); |
34 | } |
35 | return * this ; |
36 | }
http://blog.csdn.net/koilin/article/details/7599223 我有两个QComboBox combo1, combo2:
然后是信号处理函数:
这样两个combobox之间就产生了死循环。因为不管是手动改变combobox的当前index还是使用函数来设置当前的index都会发出index改变的消息,此时就需要使用关闭信号:
|
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。