• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            戰(zhàn)魂小筑

            討論群:309800774 知乎關注:http://zhihu.com/people/sunicdavy 開源項目:https://github.com/davyxu

               :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
              257 隨筆 :: 0 文章 :: 506 評論 :: 0 Trackbacks

            QtPropertyBrowser2.5中的字符串屬性對應的修改方式是一個輸入框,OnValueChange是在每次鍵入字符時發(fā)送一次.這個對于編輯器需要的邏輯來說是一種災難. Ogitor修改了其源碼,解決了這個問題:

            qteditorfactory.h 中

            QtLineEditFactory類添加如下代碼,紅色標識

            class QT_QTPROPERTYBROWSER_EXPORT QtLineEditFactory : public QtAbstractEditorFactory<QtStringPropertyManager>
            {
                Q_OBJECT
            public:
                QtLineEditFactory(QObject *parent = 0);
                ~QtLineEditFactory();
            protected:
                void connectPropertyManager(QtStringPropertyManager *manager);
                QWidget *createEditor(QtStringPropertyManager *manager, QtProperty *property,
                            QWidget *parent);
                void disconnectPropertyManager(QtStringPropertyManager *manager);
            private:
                QtLineEditFactoryPrivate *d_ptr;
                Q_DECLARE_PRIVATE(QtLineEditFactory)
                Q_DISABLE_COPY(QtLineEditFactory)
                Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QString &))
                Q_PRIVATE_SLOT(d_func(), void slotRegExpChanged(QtProperty *, const QRegExp &))
                Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QString &))
                Q_PRIVATE_SLOT(d_func(), void slotEditingFinished())
                Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
            };
            
             
            qteditorfactory.cpp中
            class QtLineEditFactoryPrivate : public EditorFactoryPrivate<QLineEdit>
            {
                QtLineEditFactory *q_ptr;
                Q_DECLARE_PUBLIC(QtLineEditFactory)
            public:
            
                void slotPropertyChanged(QtProperty *property, const QString &value);
                void slotRegExpChanged(QtProperty *property, const QRegExp &regExp);
                void slotSetValue(const QString &value);
                void slotEditingFinished();
            };
            
            void QtLineEditFactoryPrivate::slotEditingFinished()
            {
                QObject *object = q_ptr->sender();
                const QMap<QLineEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd();
                for (QMap<QLineEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor)
                    if (itEditor.key() == object) {
                        QtProperty *property = itEditor.value();
                        QtStringPropertyManager *manager = q_ptr->propertyManager(property);
                        if (!manager)
                            return;
                        QString value = static_cast<QLineEdit*>(itEditor.key())->text();
                        manager->setValue(property, value);
                        return;
                    }
            }
            
            
            QWidget *QtLineEditFactory::createEditor(QtStringPropertyManager *manager,
                    QtProperty *property, QWidget *parent)
            {
            
                QLineEdit *editor = d_ptr->createEditor(property, parent);
                QRegExp regExp = manager->regExp(property);
                if (regExp.isValid()) {
                    QValidator *validator = new QRegExpValidator(regExp, editor);
                    editor->setValidator(validator);
                }
                editor->setText(manager->value(property));
            
                connect(editor, SIGNAL(editingFinished()),
                            this, SLOT(slotEditingFinished()));
                connect(editor, SIGNAL(destroyed(QObject *)),
                            this, SLOT(slotEditorDestroyed(QObject *)));
                return editor;
            }
            
             
            這樣既可在輸入回車鍵,或者輸入框失去焦點后產(chǎn)生一個OnValueChange事件
            posted on 2011-05-06 21:11 戰(zhàn)魂小筑 閱讀(2915) 評論(1)  編輯 收藏 引用 所屬分類: 界面 接口C++/ 編程語言

            評論

            # re: 正確收到Qt屬性控件中輸入框消息 2012-09-08 21:00 任旺
            , setValue 用這個好占cpu時間啊,有什么辦法,沒有解決,  回復  更多評論
              

            97香蕉久久夜色精品国产| 亚洲中文字幕无码久久综合网| 久久人人爽人人爽人人片AV东京热| 久久久久久久久久久| 中文字幕无码精品亚洲资源网久久| 97精品伊人久久大香线蕉app| 久久国产成人| 欧美牲交A欧牲交aⅴ久久| 久久夜色tv网站| 热re99久久6国产精品免费| 国产成年无码久久久久毛片| 国产99久久久国产精品小说| 久久99精品久久久久婷婷| 精品久久久久久无码中文野结衣| 久久这里只精品99re66| 国产成人精品久久亚洲高清不卡 | 久久精品无码专区免费青青| 久久精品亚洲AV久久久无码| 伊人久久大香线蕉影院95| 成人综合伊人五月婷久久| 亚洲日韩欧美一区久久久久我| 久久精品无码免费不卡| 久久人妻少妇嫩草AV无码专区| 久久久噜噜噜久久中文字幕色伊伊| 国产成人香蕉久久久久| av色综合久久天堂av色综合在| 久久无码人妻精品一区二区三区| 久久亚洲欧美日本精品| 久久福利青草精品资源站免费| 91久久国产视频| 久久久精品免费国产四虎| 欧美精品久久久久久久自慰| 成人久久免费网站| 伊人久久综合无码成人网| 久久综合亚洲鲁鲁五月天| 亚洲国产日韩欧美综合久久| 久久男人AV资源网站| 久久综合伊人77777| 一本久久精品一区二区| 亚洲AⅤ优女AV综合久久久| 久久午夜免费视频|