简体   繁体   English

qstackedwidget无法链接到qcombobox

[英]qstackedwidget cannot link to qcombobox

I'm trying to use combo box to control multiple page. 我正在尝试使用组合框来控制多个页面。 I have created some custom widget via coding and also some QFrame in widget form too. 我已经通过编码创建了一些自定义窗口小部件,并且还以窗口小部件形式创建了一些QFrame But I can't seem to find any solution to go around this. 但是我似乎找不到解决此问题的任何解决方案。 I have try to use Qstackwidget but the program hand in the process. 我尝试使用Qstackwidget但程序会在过程中使用。

stackedWidget = new QStackedWidget;
parentLayout1 = new QWidget;
parentLayout2 = new QWidget;
layout1 = new QGridLayout(parentLayout1);
layout2 = new QGridLayout(parentLayout2);

//Default layout to be linearity
layout1->addWidget(ui->TimeL, 0,1);
layout1->addWidget(ui->FreqL, 0,7);
layout1->addWidget(time1, 1,1,3,4);
layout1->addWidget(ui->PlusL, 4,3);
layout1->addWidget(time2, 5,1,3,4);
layout1->addWidget(ui->EqualL, 8,3);
layout1->addWidget(time3, 9,1,3,4);
layout1->addWidget(freq1, 1,7,3,4);
layout1->addWidget(ui->PlusL2, 4,9);
layout1->addWidget(freq2, 5,7,3,4);
layout1->addWidget(ui->EqualL2, 8,9);
layout1->addWidget(freq3, 9,7,3,4);
layout1->addWidget(ui->ProFrame,0,15,3,2);
layout1->addWidget(ui->InfoFrame,10,15,2,2);
layout1->addWidget(ui->LinearFrame,3,15,7,2);
stackedWidget->widget(1)->show();

Can you help me out with this problem? 您能帮我解决这个问题吗? Note that I have multiple Qframe in my form. 请注意,我的表单中有多个Qframe。 But I can't seem to hide them when i only want to display 1 qframe. 但是当我只想显示1个qframe时,我似乎无法隐藏它们。

You have parentLayout1 and parentLayout2 but you never added them to the stacked widget and trying to access the second widget ( stackedWidget->widget(1) ). 您具有parentLayout1parentLayout2但是您从未将它们添加到堆叠式小部件中并尝试访问第二stackedWidget->widget(1)部件( stackedWidget->widget(1) )。 Add this before that line. 在此行之前添加它。

stackedWidget->addWidget(parentLayout1);
stackedWidget->addWidget(parentLayout2);

Also, you haven't added anything to the second layout layout2 . 另外,您还没有向第二个布局layout2添加任何layout2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM