is this a type of initialization? the constructor ButtonWidget(int widgets) seems doesnt initialize int widget. could anyone explain it in detail=? thank you.
I donot understand the code in buttonwidget.cpp
//buttonwidget.cpp
ButtonWidget::ButtonWidget( int widgets )
{
if ( widgets & ButtonWidget::ComboBoxes )
vbox->addWidget( comboBoxes() );
if ( widgets & ButtonWidget::SpinBoxes )
vbox->addWidget( spinBoxes( widgets & ButtonWidget::SpinBoxexUpdateButton ) );
if ( widgets & ButtonWidget::CheckBoxes )
vbox->addWidget( checkBoxes() );
if ( widgets & ButtonWidget::ParetoBoxes )
vbox->addWidget( paretoBoxes() );
if ( widgets & ButtonWidget::MarknDiffBoxes )
vbox->addWidget( markndiffBoxes() );
vbox->addStretch();
setLayout(vbox);
}
//buttonwidget.cpp
ButtonWidget::ButtonWidget( int widgets )
: QWidget()
{
QVBoxLayout *vbox = new QVBoxLayout();
if ( widgets & ButtonWidget::ComboBoxes )
vbox->addWidget( comboBoxes() );
if ( widgets & ButtonWidget::SpinBoxes )
vbox->addWidget( spinBoxes( widgets & ButtonWidget::SpinBoxexUpdateButton ) );
if ( widgets & ButtonWidget::CheckBoxes )
vbox->addWidget( checkBoxes() );
if ( widgets & ButtonWidget::ParetoBoxes )
vbox->addWidget( paretoBoxes() );
if ( widgets & ButtonWidget::MarknDiffBoxes )
vbox->addWidget( markndiffBoxes() );
vbox->addStretch();
setLayout(vbox);
}
To copy to clipboard, switch view to plain text mode
//buttonwidget.h
........
class ButtonWidget
: public QWidget {
Q_OBJECT
public:
enum Widgets
{
ComboBoxes = 1,
SpinBoxes = 2,
SpinBoxexUpdateButton = 4,
CheckBoxes = 8,
ParetoBoxes = 16,
MarknDiffBoxes = 32
};
ButtonWidget( int widgets );
~ButtonWidget();
.........
private:
//buttonwidget.h
........
class ButtonWidget : public QWidget
{
Q_OBJECT
public:
enum Widgets
{
ComboBoxes = 1,
SpinBoxes = 2,
SpinBoxexUpdateButton = 4,
CheckBoxes = 8,
ParetoBoxes = 16,
MarknDiffBoxes = 32
};
ButtonWidget( int widgets );
~ButtonWidget();
.........
private:
QGroupBox* comboBoxes();
QGroupBox* spinBoxes( bool updateButton );
QGroupBox* checkBoxes();
QGroupBox* paretoBoxes();
QGroupBox* markndiffBoxes();
To copy to clipboard, switch view to plain text mode
I just know the initialization as below. What kind of initialization is it in button.cpp?
class Something
02 {
03 private:
04 int m_nValue;
05 double m_dValue;
06 int *m_pnValue;
07
08 public:
09 Something()
10 {
11 m_nValue = 0;
12 m_dValue = 0.0;
13 m_pnValue = 0;
14 }
15 };
class Something
02 {
03 private:
04 int m_nValue;
05 double m_dValue;
06 int *m_pnValue;
07
08 public:
09 Something()
10 {
11 m_nValue = 0;
12 m_dValue = 0.0;
13 m_pnValue = 0;
14 }
15 };
To copy to clipboard, switch view to plain text mode
Bookmarks