代码之家  ›  专栏  ›  技术社区  ›  linjunhalida

QC++语法?

  •  0
  • linjunhalida  · 技术社区  · 17 年前

    Widget::Widget(QWidget *parent)
        : QWidget(parent), ui(new Ui::WidgetClass)
    {
        ui->setupUi(this);
    }
    

    “:QWidget(父级)、ui(新ui::WidgetClass)”是什么意思?

    我如何才能得到关于这个的C++文档?

    2 回复  |  直到 17 年前
        1
  •  8
  •   Brian R. Bondy    17 年前

    这对于QT来说并不是什么特别的东西,只是C++的一部分。

    : QWidget(parent) 正在给基本构造函数打电话。

    ui(new Ui::WidgetClass) 只是一个正在初始化的成员。

    class B
    {
    public:
      B(int x)
      {
        myx = x;
      }
    
      int myx;
    };
    
    class D : public B
    {
    public:
       D() 
       : B(4), p(new char[1024])
       {
       }
    
       ~D()
       {
         delete[] p;
       }
    
       char *p;
    };
    
        2
  •  4
  •   Ferdinand Beyer    17 年前

    初始化列表 和用于初始化类构造函数中的基类和/或成员变量。

    this document ask 'the' google .