找回密码
 立即注册
收起左侧

tabWidget标签页上new出widget

4
回复
9732
查看
[复制链接]
累计签到:18 天
连续签到:1 天
来源: 2014-11-13 09:51:19 显示全部楼层 |阅读模式
1Qter豆
  1. MainWindow::MainWindow(QWidget *parent) :
  2.     QMainWindow(parent),
  3.     ui(new Ui::MainWindow)
  4. {
  5. //! [0]
  6.     ui->setupUi(this);

  7.     tabWidget = new QTabWidget(this);
  8.     tabWidget->move(0,360);
  9.     tabWidget->resize(340,340);

  10.    
  11.     m_tab1 = new qcw_meter(this);
  12.     tabWidget->addTab(m_tab1,"123");
复制代码
我想在tabWidget的标签页m_tab1上new出4个widget,然后在每个widget上加容器类,代码应该怎么写?
我在第一步tabWidget上newwidget时就报错了...小白求教!

最佳答案

查看完整内容

文档上不是写的很清楚嘛~ The normal way to use QTabWidget is to do the following: 1. Create a QTabWidget. 2. Create a QWidget for each of the pages in the tab dialog, but do not specify parent widgets for them. 3. Insert child widgets into the page widget, using layouts to position them as normal. 4. Call addTab() or insertTab() to put the page widgets into the tab widget, giving each tab a su ...
回复

使用道具 举报

尚未签到

2014-11-13 09:51:20 显示全部楼层
qdamnitt 发表于 2014-11-13 19:37
是直接在tabWidget上加layout吗?
参照上面的代码,能帮我简单写两句吗?谢谢了! ...

文档上不是写的很清楚嘛~

The normal way to use QTabWidget is to do the following:

1. Create a QTabWidget.
2. Create a QWidget for each of the pages in the tab dialog, but do not specify parent widgets for them.
3. Insert child widgets into the page widget, using layouts to position them as normal.
4. Call addTab() or insertTab() to put the page widgets into the tab widget, giving each tab a suitable label with an optional keyboard shortcut.
回复

使用道具 举报

累计签到:344 天
连续签到:1 天
2014-11-13 14:00:57 显示全部楼层
报什么错,是报没加头文件哪种吗?
回复

使用道具 举报

尚未签到

2014-11-13 16:07:33 显示全部楼层
widget里面要先加layout才能再加widget
回复

使用道具 举报

累计签到:18 天
连续签到:1 天
2014-11-13 19:37:41 显示全部楼层
Joey_Chan 发表于 2014-11-13 16:07
widget里面要先加layout才能再加widget

是直接在tabWidget上加layout吗?
参照上面的代码,能帮我简单写两句吗?谢谢了!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

公告
可以关注我们的微信公众号yafeilinux_friends获取最新动态,或者加入QQ会员群进行交流:190741849、186601429(已满) 我知道了