I'm trying to create a custom control but with limited c++ knowledge I'm struggling a bit.
I've taken a look at the header file RadioGroup.h as I'm trying to build something with similar functionality.
Here are my 2 files:
CompanyRadioGroup.h
#ifndef COMPANYRADIOGROUP_H_
#define COMPANYRADIOGROUP_H_
#include <bb/cascades/Control>
#include <bb/cascades/Container>
#include <bb/cascades/Option>
using namespace bb::cascades;
class CompanyRadioGroup : public Control {
private:
Q_OBJECT
QDeclarativeListProperty<Option> options();
public:
CompanyRadioGroup(Container * parent = 0);
virtual ~CompanyRadioGroup();
template <typename BuilderType, typename BuiltType>
class TBuilder : public BaseClass::TBuilder<BuilderType, BuiltType>
{
protected:
TBuilder(BuiltType* node) : BaseClass::TBuilder<BuilderType, BuiltType>(node)
{
}
public:
/*!
* @copydoc bb::cascades::RadioGroup::setDividersVisible(bool)
*
* @since BlackBerry 10.0.0
*/
BuilderType& dividers(bool dividersVisible)
{
this->instance().setDividersVisible(dividersVisible);
return this->builder();
}
BuilderType& add(Option* option)
{
this->instance().add(option);
return this->builder();
}
BuilderType& add(const QString &optionText, const QVariant &value = QVariant(), bool selected = false)
{
this->instance().add(Option::create().text(optionText).value(value).selected(selected));
return this->builder();
}
};
class Builder : public TBuilder<Builder, CompanyRadioGroup>
{
public:
explicit Builder() : TBuilder<Builder, CompanyRadioGroup>(new CompanyRadioGroup())
{
}
};
static Builder create()
{
return Builder();
}
};
#endif
CompanyRadioGroup.cpp
#include "CompanyRadioGroup.h"
#include <bb/cascades/Control>
CompanyRadioGroup::CompanyRadioGroup(Container * parent) : Control(parent){
}
CompanyRadioGroup::~CompanyRadioGroup() {
// TODO Auto-generated destructor stub
}
On compiling I am getting an error
CompanyRadioGroup.cpp:12:72: error: no matching function for call to 'bb::cascades::Control::Control(bb::cascades::Container*&)'
It appears that the contructor for Control requires 2 parameters, however I cannot find any documentation on the first parameter or an example.
According to the Control.h file it has the following:
Control(ControlPrivate &_d_ptr, Control* parent = 0);
Can anyone advise how I pass _d_ptr or how I can overcome this issue?
If you do not need the first parameter _d_ptr anywhere in your code create a dummy abject instance that indicates "no-object" and pass that as the first parameter. References can't be null in c++ so you can't pass a null argument. Just create a dummy contrilPrivate object and pass a reference to it to the constructor.