#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
#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 QVBoxLayout;
class QGroupBox;
class QRadioButton;
class QPalette;
class QSize;
class QPushButton;
class QTabWidget;
/*class psudo_code:public QWidget
{
Q_OBJECT
public:
psudo_code(QWidget *parent = 0);
private:
QLabel *label1;
QVBoxLayout *main_layout1;
};*/
class v_lab:public QDialog
{
Q_OBJECT
public:
v_lab(QWidget *parent = 0);
signals:
public slots:
void peeyush();
private:
QPalette *p;
QGroupBox *maingroup;
QGroupBox *box;
QHBoxLayout *mainlayout;
QVBoxLayout *main_left_pane_layout;
QVBoxLayout *left_pane_box;
QVBoxLayout *left_pane_box1;
QVBoxLayout *left_pane_box2;
QVBoxLayout *left_pane_box3;
QGroupBox *box1;
QGroupBox *box2;
QGroupBox *box3;
QRadioButton *linear_search;
QRadioButton *binary_search;
QRadioButton *bubble_sort;
QRadioButton *selection_sort;
QRadioButton *infix_traversal;
QRadioButton *prefix_traversal;
QRadioButton *postfix_traversal;
QRadioButton *bfs;
QRadioButton *dfs;
QRadioButton *shortest_path;
QTabWidget *tab;
QString string2;
};
class algorithm:public QWidget
{
Q_OBJECT
public:
algorithm(const QString &string,QWidget *parent = 0);
private:
QLabel *label;
QLabel *label1;
QVBoxLayout *main_layout;
QVBoxLayout *main_layout1;
};
#endif // V_LAB_H
To copy to clipboard, switch view to plain text mode
source file (v_lab.cpp)
#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);
}
#include<QtGui>
#include "v_lab.h"
v_lab::v_lab(QWidget *parent)
:QDialog(parent)
{
setWindowTitle("Virtual Lab");
maingroup=new QGroupBox(this);
maingroup->setTitle("Algorithms");
maingroup->setMinimumWidth(200);
maingroup->setMaximumWidth(240);
maingroup->setFlat(false);
p=new QPalette;
p->setColor(QPalette::Background,QColor(233,212,102));
setPalette(*p);
box=new QGroupBox(maingroup);
box->setFlat(false);
box->setTitle("Searching Algorithm");
linear_search=new QRadioButton("Linear Search",box);
linear_search->setChecked(1);
binary_search=new QRadioButton("Binary Search",box);
box1=new QGroupBox(maingroup);
box1->setFlat(false);
box1->setTitle("Sorting Algorithms");
bubble_sort=new QRadioButton("Bubble Sort",box1);
selection_sort=new QRadioButton("Selection Sort",box1);
box2=new QGroupBox(maingroup);
box2->setFlat(false);
box2->setTitle("Tree Algorithms");
infix_traversal=new QRadioButton("Infix Traversal",box2);
prefix_traversal=new QRadioButton("Prefix Traversal",box2);
postfix_traversal=new QRadioButton("Postfix Traversal",box2);
box3=new QGroupBox(maingroup);
box3->setFlat(false);
box3->setTitle("Graph Algorithms");
bfs=new QRadioButton("BFS",box3);
dfs=new QRadioButton("DFS",box3);
shortest_path=new QRadioButton("Shortest Path",box3);
QString string1="Start Tab";
tab=new QTabWidget;
tab->addTab(new algorithm(string1),"Algorithm");
//tab->addTab(new psudo_code(),"Pseduo-Code");
tab->setMinimumWidth(250);
tab->setMaximumWidth(400);
//Layout
mainlayout=new QHBoxLayout(this);
mainlayout->addWidget(maingroup);
mainlayout->addWidget(tab);
mainlayout->addStretch();
main_left_pane_layout=new QVBoxLayout(maingroup);
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=new QVBoxLayout(box);
left_pane_box->addWidget(linear_search);
left_pane_box->addWidget(binary_search);
left_pane_box1=new QVBoxLayout(box1);
left_pane_box1->addWidget(bubble_sort);
left_pane_box1->addWidget(selection_sort);
left_pane_box2=new QVBoxLayout(box2);
left_pane_box2->addWidget(infix_traversal);
left_pane_box2->addWidget(prefix_traversal);
left_pane_box2->addWidget(postfix_traversal);
left_pane_box3=new QVBoxLayout(box3);
left_pane_box3->addWidget(bfs);
left_pane_box3->addWidget(dfs);
left_pane_box3->addWidget(shortest_path);
connect(binary_search,SIGNAL(clicked()),this,SLOT(peeyush()));
}
algorithm::algorithm(const QString &string,QWidget *parent)
:QWidget(parent)
{
label=new QLabel(string);
main_layout=new QVBoxLayout;
main_layout->addWidget(label);
main_layout->addStretch();
setLayout(main_layout);
}
void v_lab::peeyush()
{
string2="test 2";
new algorithm(string2);
//exit(1);
}
To copy to clipboard, switch view to plain text mode
main.cpp
#include <QApplication>
#include"v_lab.h"
int main(int argc, char *argv[])
{
v_lab *dialog = new v_lab;
dialog->show();
return app.exec();
}
#include <QApplication>
#include"v_lab.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
v_lab *dialog = new v_lab;
dialog->show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks