Problem in connecting QRadioButton to QTabWidget tab
I am creating an application in which i want a functionality in which whenever a radio button is checked,the content appearing in a tab must be changed.but the problem is when i connect the button with the tab,nothing happens.I am creating an object of a class which creates the tab firstly, within the slot to change the content of the tab whenever it will be checked. But this is not working as the content of tab is not changing.
Can any one help with this problem?
I am attaching the code of my program as well.
Header file:
Code:
#ifndef V_LAB_H
#define V_LAB_H
#include<QDialog>
#include<QVBoxLayout>
#include<QHBoxLayout>
#include<QGroupBox>
#include<QRadioButton>
#include<QPalette>
#include<QSize>
#include<QTabWidget>
#include<QLabel>
/*class psudo_code:public QWidget
{
Q_OBJECT
public:
psudo_code(QWidget *parent = 0);
private:
QLabel *label1;
QVBoxLayout *main_layout1;
};*/
{
Q_OBJECT
public:
signals:
public slots:
void peeyush();
private:
};
{
Q_OBJECT
public:
private:
};
#endif // V_LAB_H
source file (v_lab.cpp)
Code:
#include<QtGui>
#include "v_lab.h"
{
setWindowTitle("Virtual Lab");
maingroup->setTitle("Algorithms");
maingroup->setMinimumWidth(200);
maingroup->setMaximumWidth(240);
maingroup->setFlat(false);
setPalette(*p);
box->setFlat(false);
box->setTitle("Searching Algorithm");
linear_search->setChecked(1);
box1->setFlat(false);
box1->setTitle("Sorting Algorithms");
box2->setFlat(false);
box2->setTitle("Tree Algorithms");
postfix_traversal
=new QRadioButton("Postfix Traversal",box2
);
box3->setFlat(false);
box3->setTitle("Graph Algorithms");
tab->addTab(new algorithm(string1),"Algorithm");
//tab->addTab(new psudo_code(),"Pseduo-Code");
tab->setMinimumWidth(250);
tab->setMaximumWidth(400);
//Layout
mainlayout->addWidget(maingroup);
mainlayout->addWidget(tab);
mainlayout->addStretch();
main_left_pane_layout->addWidget(box);
main_left_pane_layout->addWidget(box1);
main_left_pane_layout->addWidget(box2);
main_left_pane_layout->addWidget(box3);
left_pane_box->addWidget(linear_search);
left_pane_box->addWidget(binary_search);
left_pane_box1->addWidget(bubble_sort);
left_pane_box1->addWidget(selection_sort);
left_pane_box2->addWidget(infix_traversal);
left_pane_box2->addWidget(prefix_traversal);
left_pane_box2->addWidget(postfix_traversal);
left_pane_box3->addWidget(bfs);
left_pane_box3->addWidget(dfs);
left_pane_box3->addWidget(shortest_path);
connect(binary_search,SIGNAL(clicked()),this,SLOT(peeyush()));
}
{
main_layout->addWidget(label);
main_layout->addStretch();
setLayout(main_layout);
}
void v_lab::peeyush()
{
string2="test 2";
new algorithm(string2);
//exit(1);
}
main.cpp
Code:
#include <QApplication>
#include"v_lab.h"
int main(int argc, char *argv[])
{
v_lab *dialog = new v_lab;
dialog->show();
return app.exec();
}