Qt QStackedWidget局部分页遇到BUG,急急急,回答得好的有追加
代码如下,前面槽什么的都定义好了QWidget(parent){widget=newQWidget;//左侧布局QVBoxLayout*buttonLayout=newQ...
代码如下,前面槽什么的都定义好了
QWidget(parent)
{
widget = new QWidget;
//左侧布局
QVBoxLayout *buttonLayout = new QVBoxLayout;
QWidget *leftWidget = new QWidget(this); //新建一个QWidget
buttonLayout->addWidget(leftWidget);
QPushButton *button1 = new QPushButton(leftWidget);
QPushButton *button2 = new QPushButton(leftWidget);
QPushButton *button3 = new QPushButton(leftWidget);
QPushButton *button4 = new QPushButton(leftWidget);
//右边布局
QGridLayout *rightLayout = new QGridLayout;
stackedWidget = new QStackedWidget;
rightLayout->addWidget(stackedWidget);
stackedWidget->addWidget(creat_1Page);
stackedWidget->addWidget(creat_2Page);
stackedWidget->addWidget(creat_3Page);
stackedWidget->addWidget(creat_4Page);
connect(button1, SIGNAL(clicked()),stackedWidget, SLOT(slot_1()));
connect(button2, SIGNAL(clicked()),stackedWidget, SLOT(slot_2()));
connect(button3, SIGNAL(clicked()),stackedWidget, SLOT(slot_3()));
connect(button4, SIGNAL(clicked()),stackedWidget, SLOT(slot_4()));
//双表关联
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->addLayout(buttonLayout);
mainLayout->addLayout(rightLayout);
mainLayout->addWidget(stackedWidget);
setLayout(mainLayout);
stackedWidget->showNormal();
}
Widget::~Widget()
{
}
void Widget::slot_1()
{
stackedWidget->setCurrentIndex(0);
}
void Widget::slot_2()
{
stackedWidget->setCurrentIndex(1);
}
void Widget::slot_3()
{
stackedWidget->setCurrentIndex(2);
}
void Widget::slot_4()
{
stackedWidget->setCurrentIndex(3);
}
void Widget::creatWidget_1()
{
creat_1Page = new QWidget;
}
void Widget::creatWidget_2()
{
creat_2Page = new QWidget;
}
void Widget::creatWidget_3()
{
creat_3Page = new QWidget;
}
void Widget::creatWidget_4()
{
creat_4Page = new QWidget;
}
或者谁能告诉我怎样在linux下用qt代码实现点击按钮分页。就是左边是一竖排按钮,右边实现Qwiget的分页。回答准确的有追加 展开
QWidget(parent)
{
widget = new QWidget;
//左侧布局
QVBoxLayout *buttonLayout = new QVBoxLayout;
QWidget *leftWidget = new QWidget(this); //新建一个QWidget
buttonLayout->addWidget(leftWidget);
QPushButton *button1 = new QPushButton(leftWidget);
QPushButton *button2 = new QPushButton(leftWidget);
QPushButton *button3 = new QPushButton(leftWidget);
QPushButton *button4 = new QPushButton(leftWidget);
//右边布局
QGridLayout *rightLayout = new QGridLayout;
stackedWidget = new QStackedWidget;
rightLayout->addWidget(stackedWidget);
stackedWidget->addWidget(creat_1Page);
stackedWidget->addWidget(creat_2Page);
stackedWidget->addWidget(creat_3Page);
stackedWidget->addWidget(creat_4Page);
connect(button1, SIGNAL(clicked()),stackedWidget, SLOT(slot_1()));
connect(button2, SIGNAL(clicked()),stackedWidget, SLOT(slot_2()));
connect(button3, SIGNAL(clicked()),stackedWidget, SLOT(slot_3()));
connect(button4, SIGNAL(clicked()),stackedWidget, SLOT(slot_4()));
//双表关联
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->addLayout(buttonLayout);
mainLayout->addLayout(rightLayout);
mainLayout->addWidget(stackedWidget);
setLayout(mainLayout);
stackedWidget->showNormal();
}
Widget::~Widget()
{
}
void Widget::slot_1()
{
stackedWidget->setCurrentIndex(0);
}
void Widget::slot_2()
{
stackedWidget->setCurrentIndex(1);
}
void Widget::slot_3()
{
stackedWidget->setCurrentIndex(2);
}
void Widget::slot_4()
{
stackedWidget->setCurrentIndex(3);
}
void Widget::creatWidget_1()
{
creat_1Page = new QWidget;
}
void Widget::creatWidget_2()
{
creat_2Page = new QWidget;
}
void Widget::creatWidget_3()
{
creat_3Page = new QWidget;
}
void Widget::creatWidget_4()
{
creat_4Page = new QWidget;
}
或者谁能告诉我怎样在linux下用qt代码实现点击按钮分页。就是左边是一竖排按钮,右边实现Qwiget的分页。回答准确的有追加 展开
2个回答
展开全部
威孚半导体技术
2024-08-19 广告
2024-08-19 广告
威孚(苏州)半导体技术有限公司是一家专注生产、研发、销售晶圆传输设备整机模块(EFEM/SORTER)及核心零部件的高科技半导体公司。公司核心团队均拥有多年半导体行业从业经验,其中技术团队成员博士、硕士学历占比80%以上,依托丰富的软件底层...
点击进入详情页
本回答由威孚半导体技术提供
展开全部
你画个图吧,不知道你想要什么样的布局
追问
最外面是一个QHBoxlayout布局,里面左边是一个QVBoxlayout放按钮,里面右边是分页的。点击左边的按钮实现右边分页效果
追答
widget = new QWidget;
//左侧布局
QVBoxLayout * buttonLayout = new QVBoxLayout;
button1 = new QPushButton();
button2 = new QPushButton();
button3 = new QPushButton();
button4 = new QPushButton();
buttonLayout->addWidget(button1);
buttonLayout->addWidget(button2);
buttonLayout->addWidget(button3);
buttonLayout->addWidget(button4);
//右边布局
QStackedWidget * stackedWidget = new QStackedWidget;
stackedWidget->addWidget(creat_1Page);
stackedWidget->addWidget(creat_2Page);
stackedWidget->addWidget(creat_3Page);
stackedWidget->addWidget(creat_4Page);
//双表关联
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->addLayout(buttonLayout);
mainLayout->addWidget(stackedWidget);
widget->setLayout(mainLayout);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询