0

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. 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.

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. But I can't seem to hide them when i only want to display 1 qframe.

demonplus
  • 5,613
  • 12
  • 49
  • 68

1 Answers1

1

You have parentLayout1 and parentLayout2 but you never added them to the stacked widget and trying to access the second widget (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.

ramtheconqueror
  • 1,907
  • 1
  • 22
  • 35