QHBoxLayout* hbox = new QHBoxLayout(this);
QVBoxLayout* vbox1 = new QVBoxLayout();
QVBoxLayout* vbox2 = new QVBoxLayout();
((QHBoxLayout*)layout())->addLayout(vbox1);
((QHBoxLayout*)layout())->addLayout(vbox2);
为什么我这样写运行时刻是错误的呢??
QHBoxLayout* hbox = new QHBoxLayout(this);
QVBoxLayout* vbox1 = new QVBoxLayout();
QVBoxLayout* vbox2 = new QVBoxLayout();
hbox->addLayout(vbox1);
hbox->addLayout(vbox2);
这个是正确的
((QHBoxLayout*)layout())不可以类型转换么??还是函数用的不对
获取一个窗口布局管理器是这个接口么???
我用的是QMainWindow类,好像QmainWindow本身就有个默认Layout,看了setLayout函数说明 说是已经有了Layout需要把以前的给删掉
新设置的setLayout才有效 那么怎么删掉以前的呢 是用delete 吗??
试了下好像也不行
[ 此帖被kuguoxin198在2009-10-25 22:36重新编辑 ]