QT new functions:
- add CV_RADIOBOX with exclusive mode
This commit is contained in:
parent
2c923c7eba
commit
f572047496
@ -95,7 +95,7 @@ CVAPI(int) cvStartLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* a
|
|||||||
CVAPI(void) cvStopLoop();
|
CVAPI(void) cvStopLoop();
|
||||||
|
|
||||||
typedef void (CV_CDECL *CvButtonCallback)(int state, void* userdata);
|
typedef void (CV_CDECL *CvButtonCallback)(int state, void* userdata);
|
||||||
enum {CV_PUSH_BUTTON = 0, CV_CHECKBOX = 1};
|
enum {CV_PUSH_BUTTON = 0, CV_CHECKBOX = 1, CV_RADIOBOX = 2};
|
||||||
CVAPI(int) cvCreateButton( const char* button_name CV_DEFAULT(NULL),CvButtonCallback on_change CV_DEFAULT(NULL), void* userdata CV_DEFAULT(NULL) , int button_type CV_DEFAULT(CV_PUSH_BUTTON), bool initial_button_state CV_DEFAULT(0));
|
CVAPI(int) cvCreateButton( const char* button_name CV_DEFAULT(NULL),CvButtonCallback on_change CV_DEFAULT(NULL), void* userdata CV_DEFAULT(NULL) , int button_type CV_DEFAULT(CV_PUSH_BUTTON), bool initial_button_state CV_DEFAULT(0));
|
||||||
//----------------------
|
//----------------------
|
||||||
|
|
||||||
|
@ -1028,55 +1028,65 @@ CvTrackbar::~CvTrackbar()
|
|||||||
//here CvButtonbar class
|
//here CvButtonbar class
|
||||||
CvButtonbar::CvButtonbar(QWidget* arg, QString arg2)
|
CvButtonbar::CvButtonbar(QWidget* arg, QString arg2)
|
||||||
{
|
{
|
||||||
type=type_CvButtonbar;
|
type=type_CvButtonbar;
|
||||||
myparent = arg;
|
myparent = arg;
|
||||||
name_bar = arg2;
|
name_bar = arg2;
|
||||||
setObjectName(name_bar);
|
setObjectName(name_bar);
|
||||||
|
|
||||||
/*
|
group_button = new QButtonGroup;
|
||||||
label = new QLabel;
|
|
||||||
setLabel();
|
/*
|
||||||
addWidget(label,Qt::AlignLeft );
|
label = new QLabel;
|
||||||
*/
|
setLabel();
|
||||||
|
addWidget(label,Qt::AlignLeft );
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
CvButtonbar::~CvButtonbar()
|
CvButtonbar::~CvButtonbar()
|
||||||
{
|
{
|
||||||
QLayoutItem *child;
|
QLayoutItem *child;
|
||||||
|
|
||||||
while ((child = takeAt(0)) != 0)
|
while ((child = takeAt(0)) != 0)
|
||||||
delete child;
|
delete child;
|
||||||
|
|
||||||
|
delete group_button;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CvButtonbar::setLabel()
|
void CvButtonbar::setLabel()
|
||||||
{
|
{
|
||||||
QString nameNormalized = name_bar.leftJustified( 10, ' ', true );
|
QString nameNormalized = name_bar.leftJustified( 10, ' ', true );
|
||||||
label->setText(nameNormalized);
|
label->setText(nameNormalized);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CvButtonbar::addButton( QString name, CvButtonCallback call, void* userdata, int button_type, bool initial_button_state)
|
void CvButtonbar::addButton( QString name, CvButtonCallback call, void* userdata, int button_type, bool initial_button_state)
|
||||||
{
|
{
|
||||||
QString button_name = name;
|
QString button_name = name;
|
||||||
|
|
||||||
if (button_name == "")
|
if (button_name == "")
|
||||||
button_name = tr("button %1").arg(this->count());
|
button_name = tr("button %1").arg(this->count());
|
||||||
|
|
||||||
QPointer<QAbstractButton> button;
|
QPointer<QAbstractButton> button;
|
||||||
|
|
||||||
if (button_type == CV_PUSH_BUTTON)
|
if (button_type == CV_PUSH_BUTTON)
|
||||||
//CvPushButton*
|
//CvPushButton*
|
||||||
button = (QAbstractButton*) new CvPushButton(this, button_name,call, userdata);
|
button = (QAbstractButton*) new CvPushButton(this, button_name,call, userdata);
|
||||||
|
|
||||||
if (button_type == CV_CHECKBOX)
|
if (button_type == CV_CHECKBOX)
|
||||||
//CvCheckButton*
|
//CvCheckButton*
|
||||||
button = (QAbstractButton*) new CvCheckBox(this, button_name,call, userdata, initial_button_state);
|
button = (QAbstractButton*) new CvCheckBox(this, button_name,call, userdata, initial_button_state);
|
||||||
|
|
||||||
if (button)
|
if (button_type == CV_RADIOBOX)
|
||||||
{
|
{
|
||||||
QObject::connect( button, SIGNAL( clicked() ),button, SLOT( callCallBack() ));
|
//CvCheckButton*
|
||||||
addWidget(button,Qt::AlignCenter);
|
button = (QAbstractButton*) new CvRadioButton(this, button_name,call, userdata, initial_button_state);
|
||||||
}
|
group_button->addButton(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (button)
|
||||||
|
{
|
||||||
|
QObject::connect( button, SIGNAL( clicked() ),button, SLOT( callCallBack() ));
|
||||||
|
addWidget(button,Qt::AlignCenter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1086,21 +1096,38 @@ void CvButtonbar::addButton( QString name, CvButtonCallback call, void* userdata
|
|||||||
//buttons here
|
//buttons here
|
||||||
CvPushButton::CvPushButton(CvButtonbar* arg1, QString arg2, CvButtonCallback arg3, void* arg4)
|
CvPushButton::CvPushButton(CvButtonbar* arg1, QString arg2, CvButtonCallback arg3, void* arg4)
|
||||||
{
|
{
|
||||||
myparent = arg1;
|
myparent = arg1;
|
||||||
button_name = arg2;
|
button_name = arg2;
|
||||||
callback = arg3;
|
callback = arg3;
|
||||||
userdata=arg4;
|
userdata=arg4;
|
||||||
|
|
||||||
setObjectName(button_name);
|
setObjectName(button_name);
|
||||||
setText(button_name);
|
setText(button_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CvPushButton::callCallBack()
|
void CvPushButton::callCallBack()
|
||||||
{
|
{
|
||||||
callback(-1,userdata);
|
callback(-1,userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
CvCheckBox::CvCheckBox(CvButtonbar* arg1, QString arg2, CvButtonCallback arg3, void* arg4, bool initial_button_state)
|
CvCheckBox::CvCheckBox(CvButtonbar* arg1, QString arg2, CvButtonCallback arg3, void* arg4, bool initial_button_state)
|
||||||
|
{
|
||||||
|
myparent = arg1;
|
||||||
|
button_name = arg2;
|
||||||
|
callback = arg3;
|
||||||
|
userdata=arg4;
|
||||||
|
|
||||||
|
setObjectName(button_name);
|
||||||
|
setCheckState((initial_button_state == 1?Qt::Checked:Qt::Unchecked));
|
||||||
|
setText(button_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CvCheckBox::callCallBack()
|
||||||
|
{
|
||||||
|
callback(this->isChecked(),userdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
CvRadioButton::CvRadioButton(CvButtonbar* arg1, QString arg2, CvButtonCallback arg3, void* arg4, bool initial_button_state)
|
||||||
{
|
{
|
||||||
myparent = arg1;
|
myparent = arg1;
|
||||||
button_name = arg2;
|
button_name = arg2;
|
||||||
@ -1108,11 +1135,11 @@ CvCheckBox::CvCheckBox(CvButtonbar* arg1, QString arg2, CvButtonCallback arg3, v
|
|||||||
userdata=arg4;
|
userdata=arg4;
|
||||||
|
|
||||||
setObjectName(button_name);
|
setObjectName(button_name);
|
||||||
setCheckState((initial_button_state == 1?Qt::Checked:Qt::Unchecked));
|
setChecked(initial_button_state);
|
||||||
setText(button_name);
|
setText(button_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CvCheckBox::callCallBack()
|
void CvRadioButton::callCallBack()
|
||||||
{
|
{
|
||||||
callback(this->isChecked(),userdata);
|
callback(this->isChecked(),userdata);
|
||||||
}
|
}
|
||||||
@ -1120,8 +1147,6 @@ void CvCheckBox::callCallBack()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//here CvWinProperties class
|
//here CvWinProperties class
|
||||||
CvWinProperties::CvWinProperties(QString name_paraWindow, QWidget* parent)
|
CvWinProperties::CvWinProperties(QString name_paraWindow, QWidget* parent)
|
||||||
{
|
{
|
||||||
|
@ -76,6 +76,8 @@
|
|||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
#include <QRadioButton>
|
||||||
|
#include <QButtonGroup>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
//start private enum
|
//start private enum
|
||||||
@ -159,6 +161,7 @@ private:
|
|||||||
void setLabel();
|
void setLabel();
|
||||||
|
|
||||||
QPointer<QLabel> label;
|
QPointer<QLabel> label;
|
||||||
|
QPointer<QButtonGroup> group_button;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -196,6 +199,23 @@ private slots:
|
|||||||
void callCallBack();
|
void callCallBack();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CvRadioButton : public QRadioButton
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CvRadioButton(CvButtonbar* par, QString button_name, CvButtonCallback call, void* userdata, bool initial_button_state);
|
||||||
|
|
||||||
|
private:
|
||||||
|
CvButtonbar* myparent;
|
||||||
|
QString button_name ;
|
||||||
|
CvButtonCallback callback;
|
||||||
|
void* userdata;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void callCallBack();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class CvTrackbar : public CvBar
|
class CvTrackbar : public CvBar
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user