PropEditorWidget::PropEditorWidget(ObjTreeQtModel* aObjTreeMdl, QWidget * parent, Qt::WindowFlags flags) : QDockWidget(parent, flags), Ui::RKPropEditorWidget(), mdl(aObjTreeMdl->get_object_graph(),aObjTreeMdl->get_root_node()), delegate(&mdl) { setupUi(this); this->tableView->setModel(&mdl); this->tableView->setRootIndex(QModelIndex()); this->tableView->setItemDelegate(&delegate); this->tableTab->setAttribute(Qt::WA_AlwaysShowToolTips, true); this->sourceTab->setAttribute(Qt::WA_AlwaysShowToolTips, true); connect(aObjTreeMdl, SIGNAL(objectNodeSelected(serialization::object_node_desc)), &mdl, SLOT(selectObject(serialization::object_node_desc))); connect(&mdl, SIGNAL(objectTreeChanged()), aObjTreeMdl, SLOT(treeChanged())); connect(&mdl, SIGNAL(objectNameChanged(std::string)), this, SLOT(objNameChanged(std::string))); connect(&mdl, SIGNAL(sourceDataChanged()), this, SLOT(xmlSrcChanged())); connect(this, SIGNAL(editedXMLSrc(std::string)), &mdl, SLOT(sourceDataEdited(std::string))); connect(this->applyButton, SIGNAL(clicked()), this, SLOT(applyButtonClick())); connect(this->cancelButton, SIGNAL(clicked()), this, SLOT(cancelButtonClick())); connect(this->textEdit, SIGNAL(textChanged()), this, SLOT(onTextChanged())); };
void QObject::setObjectName(const QString &name) { if (m_objectName != name) { m_objectName = name; emit objectNameChanged(m_objectName); } }
void SceneObject::setItem(const shared_ptr<Item> &item) { if (_item) _item.reset(); _item = item; connect(this, SIGNAL(objectNameChanged(QString)), item.get(), SLOT(updateObjectName(QString))); }
/* * 功能: * 构造函数,初始化有限状态机并run之。 * 参数: * 无 * 返回值: * 无 */ SlidingScreen::SlidingScreen(QGraphicsView *parent, bool isOneDirection): QGraphicsView(parent), m_isOneDirection(isOneDirection) { m_enable = false; m_enableSliding = true; m_pressPos.setX(0); m_pressPos.setY(0); m_releasePos.setX(0); m_releasePos.setY(0); p_frame1 = new QFrame(); p_frame2 = new QFrame(); p_frame3 = new QFrame(); p_layout1 = new QStackedLayout(); p_layout2 = new QStackedLayout(); p_layout3 = new QStackedLayout(); m_layOut[0] = p_layout1; m_layOut[1] = p_layout2; m_layOut[2] = p_layout3; /****初始化窗体指针缓存,索引缓存,索引缓存长度*********/ p_widgetBuf = new QVector<QWidget*>(BUF_LEN, nullptr); p_indexBuf = new QVector<int>(); p_frame1->resize(DESKTOP_WIDTH,DESKTOP_HEIGHT); p_frame2->resize(DESKTOP_WIDTH,DESKTOP_HEIGHT); p_frame3->resize(DESKTOP_WIDTH,DESKTOP_HEIGHT); p_frame1->setLayout(p_layout1); p_frame2->setLayout(p_layout2); p_frame3->setLayout(p_layout3); /**************动画类实例化**********************/ p_group = new QParallelAnimationGroup; p_frame1Animation = new QPropertyAnimation(p_frame1, "pos"); p_frame2Animation = new QPropertyAnimation(p_frame2, "pos"); p_frame3Animation = new QPropertyAnimation(p_frame3, "pos"); p_frame1Animation->setDuration(1200); p_frame2Animation->setDuration(1200); p_frame3Animation->setDuration(1200); p_frame1Animation->setEasingCurve(QEasingCurve::InOutQuad); p_frame2Animation->setEasingCurve(QEasingCurve::InOutQuad); p_frame3Animation->setEasingCurve(QEasingCurve::InOutQuad); p_group->addAnimation(p_frame1Animation); p_group->addAnimation(p_frame2Animation); p_group->addAnimation(p_frame3Animation); connect(p_group, SIGNAL(finished()), this, SLOT(slotAnimationFinish())); /***********************状态机实例化*******************************/ p_stateMachine = new QStateMachine(this); p_startState = new QState(); p_leftState1 = new QState(p_startState); p_leftState2 = new QState(p_startState); p_leftState3 = new QState(p_startState); p_rightState1 = new QState(p_startState); p_rightState2 = new QState(p_startState); p_rightState3 = new QState(p_startState); p_upState1 = new QState(p_startState); p_upState2 = new QState(p_startState); p_upState3 = new QState(p_startState); p_downState1 = new QState(p_startState); p_downState2 = new QState(p_startState); p_downState3 = new QState(p_startState); /*********************move to left state*************************************/ p_leftState1->assignProperty(p_frame1, "visible", true); p_leftState1->assignProperty(p_frame2, "visible", true); p_leftState1->assignProperty(p_frame3, "visible", false); p_leftState1->assignProperty(p_frame1, "pos", QPointF(0, DESKTOP_HEIGHT)); p_leftState1->assignProperty(p_frame2, "pos", QPointF(DESKTOP_WIDTH, DESKTOP_HEIGHT)); p_leftState1->assignProperty(p_frame3, "pos", QPointF(2*DESKTOP_WIDTH, DESKTOP_HEIGHT)); p_leftState1->assignProperty(p_frame1, "objectName", QString("1")); //存放当前显示的frame索引号 p_leftState2->assignProperty(p_frame2, "visible", true); p_leftState2->assignProperty(p_frame3, "visible", true); p_leftState2->assignProperty(p_frame1, "visible", false); p_leftState2->assignProperty(p_frame2, "pos", QPointF(0, DESKTOP_HEIGHT)); p_leftState2->assignProperty(p_frame3, "pos", QPointF(DESKTOP_WIDTH, DESKTOP_HEIGHT)); p_leftState2->assignProperty(p_frame1, "pos", QPointF(DESKTOP_WIDTH*2, DESKTOP_HEIGHT)); p_leftState2->assignProperty(p_frame1, "objectName", QString("2")); p_leftState3->assignProperty(p_frame3, "visible", true); p_leftState3->assignProperty(p_frame1, "visible", true); p_leftState3->assignProperty(p_frame2, "visible", false); p_leftState3->assignProperty(p_frame3, "pos", QPointF(0, DESKTOP_HEIGHT)); p_leftState3->assignProperty(p_frame1, "pos", QPointF(DESKTOP_WIDTH, DESKTOP_HEIGHT)); p_leftState3->assignProperty(p_frame2, "pos", QPointF(DESKTOP_WIDTH*2, DESKTOP_HEIGHT)); p_leftState3->assignProperty(p_frame1, "objectName", QString("0")); /***************move to right state*********************************/ p_rightState1->assignProperty(p_frame1, "visible", false); p_rightState1->assignProperty(p_frame2, "visible", true); p_rightState1->assignProperty(p_frame3, "visible", true); p_rightState1->assignProperty(p_frame1, "pos", QPointF(0, DESKTOP_HEIGHT)); p_rightState1->assignProperty(p_frame2, "pos", QPointF(DESKTOP_WIDTH, DESKTOP_HEIGHT)); p_rightState1->assignProperty(p_frame3, "pos", QPointF(DESKTOP_WIDTH*2, DESKTOP_HEIGHT)); p_rightState1->assignProperty(p_frame1, "objectName", QString("1")); p_rightState2->assignProperty(p_frame2, "visible", false); p_rightState2->assignProperty(p_frame3, "visible", true); p_rightState2->assignProperty(p_frame1, "visible", true); p_rightState2->assignProperty(p_frame2, "pos", QPointF(0, DESKTOP_HEIGHT)); p_rightState2->assignProperty(p_frame3, "pos", QPointF(DESKTOP_WIDTH, DESKTOP_HEIGHT)); p_rightState2->assignProperty(p_frame1, "pos", QPointF(DESKTOP_WIDTH*2, DESKTOP_HEIGHT)); p_rightState2->assignProperty(p_frame1, "objectName", QString("2")); p_rightState3->assignProperty(p_frame3, "visible", false); p_rightState3->assignProperty(p_frame1, "visible", true); p_rightState3->assignProperty(p_frame2, "visible", true); p_rightState3->assignProperty(p_frame3, "pos", QPointF(0, DESKTOP_HEIGHT)); p_rightState3->assignProperty(p_frame1, "pos", QPointF(DESKTOP_WIDTH, DESKTOP_HEIGHT)); p_rightState3->assignProperty(p_frame2, "pos", QPointF(DESKTOP_WIDTH*2, DESKTOP_HEIGHT)); p_rightState3->assignProperty(p_frame1, "objectName", QString("0")); /***********************move to up state******************************************/ p_upState1->assignProperty(p_frame1, "visible", true); p_upState1->assignProperty(p_frame2, "visible", true); p_upState1->assignProperty(p_frame3, "visible", false); p_upState1->assignProperty(p_frame1, "pos", QPointF(DESKTOP_WIDTH, 0)); p_upState1->assignProperty(p_frame2, "pos", QPointF(DESKTOP_WIDTH, DESKTOP_HEIGHT)); p_upState1->assignProperty(p_frame3, "pos", QPointF(DESKTOP_WIDTH, DESKTOP_HEIGHT*2)); p_upState1->assignProperty(p_frame1, "objectName", QString("1")); p_upState2->assignProperty(p_frame2, "visible", true); p_upState2->assignProperty(p_frame3, "visible", true); p_upState2->assignProperty(p_frame1, "visible", false); p_upState2->assignProperty(p_frame2, "pos", QPointF(DESKTOP_WIDTH, 0)); p_upState2->assignProperty(p_frame3, "pos", QPointF(DESKTOP_WIDTH, DESKTOP_HEIGHT)); p_upState2->assignProperty(p_frame1, "pos", QPointF(DESKTOP_WIDTH, DESKTOP_HEIGHT*2)); p_upState2->assignProperty(p_frame1, "objectName", QString("2")); p_upState3->assignProperty(p_frame3, "visible", true); p_upState3->assignProperty(p_frame1, "visible", true); p_upState3->assignProperty(p_frame2, "visible", false); p_upState3->assignProperty(p_frame3, "pos", QPointF(DESKTOP_WIDTH, 0)); p_upState3->assignProperty(p_frame1, "pos", QPointF(DESKTOP_WIDTH, DESKTOP_HEIGHT)); p_upState3->assignProperty(p_frame2, "pos", QPointF(DESKTOP_WIDTH, DESKTOP_HEIGHT*2)); p_upState3->assignProperty(p_frame1, "objectName", QString("0")); /*************************move to down state *************************************/ p_downState1->assignProperty(p_frame1, "visible", false); p_downState1->assignProperty(p_frame2, "visible", true); p_downState1->assignProperty(p_frame3, "visible", true); p_downState1->assignProperty(p_frame1, "pos", QPointF(DESKTOP_WIDTH, 0)); p_downState1->assignProperty(p_frame2, "pos", QPointF(DESKTOP_WIDTH, DESKTOP_HEIGHT)); p_downState1->assignProperty(p_frame3, "pos", QPointF(DESKTOP_WIDTH, DESKTOP_HEIGHT*2)); p_downState1->assignProperty(p_frame1, "objectName", QString("1")); p_downState2->assignProperty(p_frame2, "visible", false); p_downState2->assignProperty(p_frame3, "visible", true); p_downState2->assignProperty(p_frame1, "visible", true); p_downState2->assignProperty(p_frame2, "pos", QPointF(DESKTOP_WIDTH, 0)); p_downState2->assignProperty(p_frame3, "pos", QPointF(DESKTOP_WIDTH, DESKTOP_HEIGHT)); p_downState2->assignProperty(p_frame1, "pos", QPointF(DESKTOP_WIDTH, DESKTOP_HEIGHT*2)); p_downState2->assignProperty(p_frame1, "objectName", QString("2")); p_downState3->assignProperty(p_frame3, "visible", false); p_downState3->assignProperty(p_frame1, "visible", true); p_downState3->assignProperty(p_frame2, "visible", true); p_downState3->assignProperty(p_frame3, "pos", QPointF(DESKTOP_WIDTH, 0)); p_downState3->assignProperty(p_frame1, "pos", QPointF(DESKTOP_WIDTH, DESKTOP_HEIGHT)); p_downState3->assignProperty(p_frame2, "pos", QPointF(DESKTOP_WIDTH, DESKTOP_HEIGHT*2)); p_downState3->assignProperty(p_frame1, "objectName", QString("0")); /*************************收到向右滑动信号*********************绑定状态切换转换和动画效果***/ QSignalTransition *rightTransition = p_rightState1->addTransition(this, SIGNAL(sigMoveRight()), p_rightState3); rightTransition->addAnimation(p_group); rightTransition = p_rightState2->addTransition(this, SIGNAL(sigMoveRight()), p_rightState1); rightTransition->addAnimation(p_group); rightTransition = p_rightState3->addTransition(this, SIGNAL(sigMoveRight()), p_rightState2); rightTransition->addAnimation(p_group); rightTransition = p_leftState1->addTransition(this, SIGNAL(sigMoveRight()), p_rightState3); rightTransition->addAnimation(p_group); rightTransition = p_leftState2->addTransition(this, SIGNAL(sigMoveRight()), p_rightState1); rightTransition->addAnimation(p_group); rightTransition = p_leftState3->addTransition(this, SIGNAL(sigMoveRight()), p_rightState2); rightTransition->addAnimation(p_group); p_upState1->addTransition(this, SIGNAL(sigMoveRight()), p_rightState1); p_upState2->addTransition(this, SIGNAL(sigMoveRight()), p_rightState2); p_upState3->addTransition(this, SIGNAL(sigMoveRight()), p_rightState3); p_downState1->addTransition(this, SIGNAL(sigMoveRight()), p_rightState1); p_downState2->addTransition(this, SIGNAL(sigMoveRight()), p_rightState2); p_downState3->addTransition(this, SIGNAL(sigMoveRight()), p_rightState3); /*************************收到向左滑动信号*********************绑定状态切换转换和动画效果***/ QSignalTransition *leftTransition = p_leftState1->addTransition(this, SIGNAL(sigMoveLeft()), p_leftState2); leftTransition->addAnimation(p_group); leftTransition = p_leftState2->addTransition(this, SIGNAL(sigMoveLeft()), p_leftState3); leftTransition->addAnimation(p_group); leftTransition = p_leftState3->addTransition(this, SIGNAL(sigMoveLeft()), p_leftState1); leftTransition->addAnimation(p_group); leftTransition = p_rightState1->addTransition(this, SIGNAL(sigMoveLeft()), p_leftState2); leftTransition->addAnimation(p_group); leftTransition = p_rightState2->addTransition(this, SIGNAL(sigMoveLeft()), p_leftState3); leftTransition->addAnimation(p_group); leftTransition = p_rightState3->addTransition(this, SIGNAL(sigMoveLeft()), p_leftState1); leftTransition->addAnimation(p_group); p_upState1->addTransition(this, SIGNAL(sigMoveLeft()), p_leftState1); p_upState2->addTransition(this, SIGNAL(sigMoveLeft()), p_leftState2); p_upState3->addTransition(this, SIGNAL(sigMoveLeft()), p_leftState3); p_downState1->addTransition(this, SIGNAL(sigMoveLeft()), p_leftState1); p_downState2->addTransition(this, SIGNAL(sigMoveLeft()), p_leftState2); p_downState3->addTransition(this, SIGNAL(sigMoveLeft()), p_leftState3); /*************************收到向上滑动信号*********************绑定状态切换转换和动画效果***/ QSignalTransition *upTransition = p_upState1->addTransition(this, SIGNAL(sigMoveUp()), p_upState2); upTransition->addAnimation(p_group); upTransition = p_upState2->addTransition(this, SIGNAL(sigMoveUp()), p_upState3); upTransition->addAnimation(p_group); upTransition = p_upState3->addTransition(this, SIGNAL(sigMoveUp()), p_upState1); upTransition->addAnimation(p_group); upTransition = p_downState1->addTransition(this, SIGNAL(sigMoveUp()), p_upState2); upTransition->addAnimation(p_group); upTransition = p_downState2->addTransition(this, SIGNAL(sigMoveUp()), p_upState3); upTransition->addAnimation(p_group); upTransition = p_downState3->addTransition(this, SIGNAL(sigMoveUp()), p_upState1); upTransition->addAnimation(p_group); p_leftState1->addTransition(this, SIGNAL(sigMoveUp()), p_upState1); p_leftState2->addTransition(this, SIGNAL(sigMoveUp()), p_upState2); p_leftState3->addTransition(this, SIGNAL(sigMoveUp()), p_upState3); p_rightState1->addTransition(this, SIGNAL(sigMoveUp()), p_upState1); p_rightState2->addTransition(this, SIGNAL(sigMoveUp()), p_upState2); p_rightState3->addTransition(this, SIGNAL(sigMoveUp()), p_upState3); /*************************收到向下滑动信号*********************绑定状态切换转换和动画效果***/ QSignalTransition *downTransition = p_downState1->addTransition(this, SIGNAL(sigMoveDown()), p_downState3); downTransition->addAnimation(p_group); downTransition = p_downState2->addTransition(this, SIGNAL(sigMoveDown()), p_downState1); downTransition->addAnimation(p_group); downTransition = p_downState3->addTransition(this, SIGNAL(sigMoveDown()), p_downState2); downTransition->addAnimation(p_group); downTransition = p_upState1->addTransition(this, SIGNAL(sigMoveDown()), p_downState3); downTransition->addAnimation(p_group); downTransition = p_upState2->addTransition(this, SIGNAL(sigMoveDown()), p_downState1); downTransition->addAnimation(p_group); downTransition = p_upState3->addTransition(this, SIGNAL(sigMoveDown()), p_downState2); downTransition->addAnimation(p_group); p_leftState1->addTransition(this, SIGNAL(sigMoveDown()), p_downState1); p_leftState2->addTransition(this, SIGNAL(sigMoveDown()), p_downState2); p_leftState3->addTransition(this, SIGNAL(sigMoveDown()), p_downState3); p_rightState1->addTransition(this, SIGNAL(sigMoveDown()), p_downState1); p_rightState2->addTransition(this, SIGNAL(sigMoveDown()), p_downState2); p_rightState3->addTransition(this, SIGNAL(sigMoveDown()), p_downState3); /**************************收到恢复初始状态信号*******************************************/ p_leftState1->addTransition(this, SIGNAL(sigInitState()), p_leftState1); p_leftState2->addTransition(this, SIGNAL(sigInitState()), p_leftState1); p_leftState3->addTransition(this, SIGNAL(sigInitState()), p_leftState1); p_rightState1->addTransition(this, SIGNAL(sigInitState()), p_leftState1); p_rightState2->addTransition(this, SIGNAL(sigInitState()), p_leftState1); p_rightState3->addTransition(this, SIGNAL(sigInitState()), p_leftState1); p_upState1->addTransition(this, SIGNAL(sigInitState()), p_leftState1); p_upState2->addTransition(this, SIGNAL(sigInitState()), p_leftState1); p_upState3->addTransition(this, SIGNAL(sigInitState()), p_leftState1); p_downState1->addTransition(this, SIGNAL(sigInitState()), p_leftState1); p_downState2->addTransition(this, SIGNAL(sigInitState()), p_leftState1); p_downState3->addTransition(this, SIGNAL(sigInitState()), p_leftState1); /************************初始化状态机和场景并关联之***********************************/ p_scene = new QGraphicsScene(this); p_scene->addWidget(p_frame1); p_scene->addWidget(p_frame2); p_scene->addWidget(p_frame3); p_scene->setSceneRect(DESKTOP_WIDTH,DESKTOP_HEIGHT, DESKTOP_WIDTH, DESKTOP_HEIGHT); setScene(p_scene); p_startState->setInitialState(p_leftState1); m_isXDirection = true; m_currentWidgetIndex = 1; //这个值跟初始状态当前显示索引有关 m_currentFrameIndexl = 1; p_stateMachine->addState(p_startState); p_stateMachine->setInitialState(p_startState); p_stateMachine->start(); connect(p_frame1, SIGNAL(objectNameChanged(QString)), this, SLOT(slotSendCurrentWidgetPointer(QString))); }
void QDesignerIntegrationInterface::emitObjectNameChanged(QDesignerFormWindowInterface *formWindow, QObject *object, const QString &newName, const QString &oldName) { emit objectNameChanged(formWindow, object, newName, oldName); }
int main (int argc, char** argv) { QApplication app(argc, argv); QWidget wgt; QStringList list; list << "1" << "2" << "3" <<"4"; QTableWidget mytable(4, 5); QTableWidgetItem* pw = NULL; mytable.setHorizontalHeaderLabels(list); mytable.setVerticalHeaderLabels(list); QBrush br(Qt::BackgroundColorRole, Qt::NoBrush); for(int i(0);i < 4; i++) for(int j(0); j < 5; j++){ pw = new QTableWidgetItem(QString("%10, %11").arg(i).arg(j)); pw->setBackground(br); //pw->setBackgroundColor(QColor::black()); //pw->setBackgroundColor(&c); mytable.setItem(i, j, pw); } QComboBox* box = new QComboBox; box->addItems(list); QString str ("111"); QTabWidget tab; // foreach(QString str, list){ // tab.addTab(new QLabel(str, &tab), str); // } QLabel* la = new QLabel(str, &tab); tab.addTab(la, QString("1")); tab.addTab(new QLineEdit, str); QToolBox * gg = new QToolBox; gg->addItem(new QLineEdit, QString("222")); QLabel* plblDisplay = new QLabel; plblDisplay->setFrameStyle(QFrame::Box | QFrame::Raised); plblDisplay->setLineWidth(5); plblDisplay->setFixedHeight(50); QLabel* plblText = new QLabel("&Text:"); QLineEdit* text = new QLineEdit; text->setInputMask("0-(000)-000-00-00"); QLineEdit* text3 = new QLineEdit; text3->setInputMask("0-(000)-000-00-00"); tab.addTab(text3, QString("0-(000)-000-00-00")); QWidget::connect(tab.widget(0), SIGNAL(objectNameChanged(QString)),tab.widget(2), SLOT(setEnabled(bool))); QTextEdit* text2 = new QTextEdit; text2->setHtml("<html><div><center><h3>I wrote the HTML</h3></center></div></html>"); MyHighlighter* pHighlighter = new MyHighlighter(text2->document()); QLineEdit* ptxt = new QLineEdit; plblText->setBuddy(ptxt); QObject::connect(ptxt, SIGNAL(textChanged(const QString&)), plblDisplay, SLOT(setText(const QString&)) ); QObject::connect(text, SIGNAL(textChanged(const QString&)), plblDisplay, SLOT(setText(const QString&)) ); QObject::connect(text2, SIGNAL(windowTitleChanged(QString)), plblDisplay, SLOT(setText(const QString&)) ); QLabel* plblPassword = new QLabel("&Password:"); QLineEdit* ptxtPassword = new QLineEdit; plblPassword->setBuddy(ptxtPassword); ptxtPassword->setEchoMode(QLineEdit::Password); ptxtPassword->setValidator(new QIntValidator); QObject::connect(ptxtPassword, SIGNAL(textChanged(const QString&)), plblDisplay, SLOT(setText(const QString&)) ); //Layout setup QVBoxLayout* pvbxLayout = new QVBoxLayout; pvbxLayout->addWidget(plblDisplay); pvbxLayout->addWidget(plblText); pvbxLayout->addWidget(ptxt); pvbxLayout->addWidget(plblPassword); pvbxLayout->addWidget(ptxtPassword); pvbxLayout->addWidget(text); pvbxLayout->addWidget(text2); pvbxLayout->addWidget(box); pvbxLayout->addWidget(&tab); pvbxLayout->addWidget(&mytable); pvbxLayout->addWidget(gg); wgt.setLayout(pvbxLayout); wgt.show(); return app.exec(); }
void Action::setObjectName(const QString &name) { QObject::setObjectName(name); emit objectNameChanged(); }