• 3341阅读
  • 5回复

怎样追加一个按钮 [复制链接]

上一主题 下一主题
离线robertkun
 

只看楼主 倒序阅读 楼主  发表于: 2009-05-19
怎样追加一个按钮:

    QHBoxLayout *layout = new QHBoxLayout();
    QWidget* myWidget = new QWidget(this);

    QPushButton hello( "Hello world!", 0 );
    hello.resize( 500, 200 );

    myWidget->setAutoFillBackground(true);
    myWidget->setFixedWidth(300);
    myWidget->setPalette(Qt::red);
    layout->addWidget(myWidget);

菜鸟报到,大虾们指点一下迷经。。
                                              简单的生活使人快乐!
离线yleesun

只看该作者 1楼 发表于: 2009-05-19
layout->addWidget(hello);
这样!
离线robertkun

只看该作者 2楼 发表于: 2009-05-19
1楼的 yleesun
1>.\testqt7.cpp(23) : error C2664: 'QBoxLayout::addWidget' : cannot convert parameter 1 from 'QPushButton' to 'QWidget *'
1>        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

编译报告这个错误。。
                                              简单的生活使人快乐!
离线robertkun

只看该作者 3楼 发表于: 2009-05-19
在线的回贴。
                                              简单的生活使人快乐!
离线溟阡
只看该作者 4楼 发表于: 2009-05-19
layout->addWidget(hello);
myWidget->setLayout(layout);
离线robertkun

只看该作者 5楼 发表于: 2009-05-19
好的,解救了,原来是没有创建指针型的 BUTTON.  谢谢各位了。。
                                              简单的生活使人快乐!
快速回复
限100 字节
 
上一个 下一个