PropertyAxisView::PropertyAxisView(QWidget *parent) : QDialog(parent){ setupUi(this); //... QSignalMapper *tickLabelSignalMapper = new QSignalMapper(this); connect(tickLabelSignalMapper, SIGNAL(mapped(int)), this, SIGNAL(tickLabelChanged(int))); tickLabelSignalMapper->setMapping(rdBtnTickLabelAuto, Label_Auto); connect(rdBtnTickLabelAuto, SIGNAL(toggled(bool)), tickLabelSignalMapper, SLOT(map())); tickLabelSignalMapper->setMapping(rdBtnTickLabelManual, Label_Manual); connect(rdBtnTickLabelManual, SIGNAL(toggled(bool)), tickLabelSignalMapper, SLOT(map()));}
void PropertyAxis::ConnectView(){ bool result; result = connect(view(), SIGNAL(tickLabelChanged(int)), this, SLOT(setTickLabel(int)));}
#ifndef PROPERTYAXISVIEW_H#define PROPERTYAXISVIEW_H#include <QDialog>#include <QButtonGroup>#include "ui_PropertyAxisView.h"#include "Enums.h"class PropertyAxisView : public QDialog, public Ui::PropertyAxisView{ Q_OBJECT Q_ENUMS(TickLocations TickLabel)public: PropertyAxisView(QWidget *parent = 0); public slots:signals: void tickLabelChanged(int);};#endif
#ifndef PROPERTYAXIS_H#define PROPERTYAXIS_H#include <QDialog>#include <qnamespace.h>#include <QObject>#include "PropertyAxisView.h"class PropertyAxis : public QObject{ Q_OBJECT Q_ENUMS(Place ScaleFormat NumberFormat TickLocations TickLabel) Q_PROPERTY(PropertyAxisView* view READ view WRITE setView) //... //... Q_PROPERTY(TickLabel tickLabel READ tickLabel WRITE setTickLabel)public: PropertyAxis();private: void ConnectView(); void DisconnectView();public: PropertyAxisView* view() const; //... //... TickLabel tickLabel() const;public slots: void setView(PropertyAxisView* pView); //... //... void setTickLabel(TickLabel tickType);signals: void viewChanged(PropertyAxisView* pView); //... //... void tickLabelChanged(TickLabel tickType);private: PropertyAxisView* m_pView; //... //... TickLabel m_tickLabel;};#endif
setTickLocations(int val){ setTickLocations( (TickLocations)val );}
C++ (Qt)setTickLocations(int val){ TickLocations value = static_cast<TickLocations>(val); //do something with value}
C++ (Qt)connect(view()->bGTickLocations, SIGNAL(buttonClicked(int)), this, SLOT(setTickLocations(int)));
C++ (Qt)connect(bGTickLocations, SIGNAL(buttonClicked(int)), this, SIGNAL(tickLabelChanged(int)));
C++ (Qt)connect(view(), SIGNAL(tickLabelChanged(int)), this, SLOT(setTickLocations(int)));