请大虾帮我看看,不知道哪里出错!

newtrain 2006-06-04 04:31:24
class Curve : public TLabel
{

public:
int x,y,w,h;
TColor c, cb;
int b;
int dt;
int t;
int data_max;
int data0, data1;

Curve(int x0,int y0,int w0,int h0,QColor c0,QColor cb0,int b0,int dt0,int data_max0)
{
x=x0; y=y0; w=w0; h=h0;
this->Left=x;
this->Top=y;
this->Width=w;
this->Height=h;
c=c0;
cb=cb0;

b=b0;

data0=data1=t=0;
dt=dt0;
data_max=data_max0;
}

};

错误提示:Type name expected;
我想在窗体中使用它:Curve *Label1;
...全文
75 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
newtrain 2006-06-04
  • 打赏
  • 举报
回复
没写了 啊
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
Label1=new Curve(10, 0, 600, 120, clRed, clBlack, 5, 1, 255,this);
}
newtrain 2006-06-04
  • 打赏
  • 举报
回复
收到了 ,谢谢!
rainfall19831109 2006-06-04
  • 打赏
  • 举报
回复
楼主看看你在new了以后写了哪些代码
我觉得是因为你没有给Label1指定Parent属性

我刚才在自己机上测试通过了,没问题的
rainfall19831109 2006-06-04
  • 打赏
  • 举报
回复
已给你回信息了
newtrain 2006-06-04
  • 打赏
  • 举报
回复
写错了 是TColor ,谢谢!
构造函数我改成:Curve::Curve(int x0,int y0,int w0,int h0,TColor c0,TColor cb0,int b0,int dt0,int data_max0,TComponent* Owner):TLabel(Owner){}
我的目的是在Form中像添加Tlabel组建一样添加一个我定义的Curve ,我现在在TForm1中的Public :Curve *Label1;
然后在TForm1的构造函数中加入 :Label1=new Curve(10, 0, 600, 120, clRed, clBlack, 5, 1, 255,this);编译没错,但运行出错:control has no parent windows!
什么原因阿!请指教!
rainfall19831109 2006-06-04
  • 打赏
  • 举报
回复
QColor是个什么类型?好像看不到声明

另外,因为你写的类是从TLabel类中继承,因此需要对基类进行构造
就想你打开一个Application时,TForm1对基类TForm的构造一样

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧