Nanda
24th January 2012, 04:52
This is my code...
1. main.cpp
#include <QtGui/QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
2. mainwindow.cpp (This is mainwindow.cpp file where i am connecting my 1st & 2nd button in textbox and in that window only the message is displaying)
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(ui->CarInternals,SIGNAL(clicked()),this,SLOT(CarIntern als_Clicked()));
connect(ui->TellTales,SIGNAL(clicked()),this,SLOT(TellTales_Cl icked()));
// connect(ui->CarInternals, SIGNAL(clicked()), setFocus, SLOT(setFocus()));
}
MainWindow::~MainWindow()
{
delete ui;
}
3. mainwindow.h (This is my header file)
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private slots:
void CarInternals_Clicked();
void TellTales_Clicked();
// void setFocus();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
void MainWindow::CarInternals_Clicked()
{
ui->Message->setText( "Car Internals Button clicked ..." );
}
void MainWindow::TellTales_Clicked()
{
ui->Message->setText( "Tell Tales Button clicked ..." );
}
/*void MainWindow::setFocus(), SLOT(screen2.ui)
{
} */
4. mainwindow.ui (this is my 1st UI file.)
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QPushButton" name="CarInternals">
<property name="geometry">
<rect>
<x>50</x>
<y>20</y>
<width>121</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Car Internals</string>
</property>
</widget>
<widget class="QPushButton" name="TellTales">
<property name="geometry">
<rect>
<x>220</x>
<y>20</y>
<width>121</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Tell Tales</string>
</property>
</widget>
<widget class="QPushButton" name="AudioSystems">
<property name="geometry">
<rect>
<x>50</x>
<y>70</y>
<width>121</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Audio System</string>
</property>
</widget>
<widget class="QPushButton" name="WeeklyChecks">
<property name="geometry">
<rect>
<x>220</x>
<y>70</y>
<width>121</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Weekly Checks</string>
</property>
</widget>
<widget class="QPushButton" name="AirConditioner">
<property name="geometry">
<rect>
<x>50</x>
<y>120</y>
<width>121</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Air Conditioner</string>
</property>
</widget>
<widget class="QPushButton" name="TeoubleShooting">
<property name="geometry">
<rect>
<x>220</x>
<y>120</y>
<width>121</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Trouble Shooting</string>
</property>
</widget>
<widget class="QPushButton" name="EHub">
<property name="geometry">
<rect>
<x>50</x>
<y>170</y>
<width>121</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>E-Hub</string>
</property>
</widget>
<widget class="QPushButton" name="Back">
<property name="geometry">
<rect>
<x>220</x>
<y>170</y>
<width>121</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Back</string>
</property>
</widget>
<widget class="QTextEdit" name="Message">
<property name="geometry">
<rect>
<x>70</x>
<y>220</y>
<width>291</width>
<height>89</height>
</rect>
</property>
</widget>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
5. screen2.ui (This is my 2nd UI file)
I want to connect my 1st UI Screen when i click on "Car Internals" it shud go the screen2 and display the list view.
The following is my 2nd screen2.ui code
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>370</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>50</x>
<y>20</y>
<width>331</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Car Internals Contain the Following List</string>
</property>
</widget>
<widget class="QListView" name="listView">
<property name="geometry">
<rect>
<x>70</x>
<y>60</y>
<width>256</width>
<height>251</height>
</rect>
</property>
</widget>
<widget class="QCommandLinkButton" name="commandLinkButton">
<property name="geometry">
<rect>
<x>90</x>
<y>90</y>
<width>178</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>Seat</string>
</property>
</widget>
<widget class="QCommandLinkButton" name="commandLinkButton_2">
<property name="geometry">
<rect>
<x>90</x>
<y>120</y>
<width>178</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>Seat Belt</string>
</property>
</widget>
<widget class="QCommandLinkButton" name="commandLinkButton_3">
<property name="geometry">
<rect>
<x>90</x>
<y>150</y>
<width>178</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>Air Bags</string>
</property>
</widget>
<widget class="QCommandLinkButton" name="commandLinkButton_4">
<property name="geometry">
<rect>
<x>90</x>
<y>180</y>
<width>178</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>Mirrors</string>
</property>
</widget>
<widget class="QCommandLinkButton" name="commandLinkButton_5">
<property name="geometry">
<rect>
<x>90</x>
<y>210</y>
<width>178</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>Storage Compartment</string>
</property>
</widget>
<widget class="QCommandLinkButton" name="commandLinkButton_6">
<property name="geometry">
<rect>
<x>90</x>
<y>240</y>
<width>178</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>Back</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
these are the 5 files where i have written the code. I want to connect my 1st UI screen which consists of the button "Car Internals" When i click on the "Car Internals button it shud go the next screen. i.e., screen2. Similarly I want to do foe all the buttons which i have shown in the mainwindow.ui file.
Please help...
Thank You Sir/Ma'am.
1. main.cpp
#include <QtGui/QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
2. mainwindow.cpp (This is mainwindow.cpp file where i am connecting my 1st & 2nd button in textbox and in that window only the message is displaying)
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(ui->CarInternals,SIGNAL(clicked()),this,SLOT(CarIntern als_Clicked()));
connect(ui->TellTales,SIGNAL(clicked()),this,SLOT(TellTales_Cl icked()));
// connect(ui->CarInternals, SIGNAL(clicked()), setFocus, SLOT(setFocus()));
}
MainWindow::~MainWindow()
{
delete ui;
}
3. mainwindow.h (This is my header file)
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private slots:
void CarInternals_Clicked();
void TellTales_Clicked();
// void setFocus();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
void MainWindow::CarInternals_Clicked()
{
ui->Message->setText( "Car Internals Button clicked ..." );
}
void MainWindow::TellTales_Clicked()
{
ui->Message->setText( "Tell Tales Button clicked ..." );
}
/*void MainWindow::setFocus(), SLOT(screen2.ui)
{
} */
4. mainwindow.ui (this is my 1st UI file.)
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QPushButton" name="CarInternals">
<property name="geometry">
<rect>
<x>50</x>
<y>20</y>
<width>121</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Car Internals</string>
</property>
</widget>
<widget class="QPushButton" name="TellTales">
<property name="geometry">
<rect>
<x>220</x>
<y>20</y>
<width>121</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Tell Tales</string>
</property>
</widget>
<widget class="QPushButton" name="AudioSystems">
<property name="geometry">
<rect>
<x>50</x>
<y>70</y>
<width>121</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Audio System</string>
</property>
</widget>
<widget class="QPushButton" name="WeeklyChecks">
<property name="geometry">
<rect>
<x>220</x>
<y>70</y>
<width>121</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Weekly Checks</string>
</property>
</widget>
<widget class="QPushButton" name="AirConditioner">
<property name="geometry">
<rect>
<x>50</x>
<y>120</y>
<width>121</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Air Conditioner</string>
</property>
</widget>
<widget class="QPushButton" name="TeoubleShooting">
<property name="geometry">
<rect>
<x>220</x>
<y>120</y>
<width>121</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Trouble Shooting</string>
</property>
</widget>
<widget class="QPushButton" name="EHub">
<property name="geometry">
<rect>
<x>50</x>
<y>170</y>
<width>121</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>E-Hub</string>
</property>
</widget>
<widget class="QPushButton" name="Back">
<property name="geometry">
<rect>
<x>220</x>
<y>170</y>
<width>121</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Back</string>
</property>
</widget>
<widget class="QTextEdit" name="Message">
<property name="geometry">
<rect>
<x>70</x>
<y>220</y>
<width>291</width>
<height>89</height>
</rect>
</property>
</widget>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
5. screen2.ui (This is my 2nd UI file)
I want to connect my 1st UI Screen when i click on "Car Internals" it shud go the screen2 and display the list view.
The following is my 2nd screen2.ui code
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>370</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>50</x>
<y>20</y>
<width>331</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Car Internals Contain the Following List</string>
</property>
</widget>
<widget class="QListView" name="listView">
<property name="geometry">
<rect>
<x>70</x>
<y>60</y>
<width>256</width>
<height>251</height>
</rect>
</property>
</widget>
<widget class="QCommandLinkButton" name="commandLinkButton">
<property name="geometry">
<rect>
<x>90</x>
<y>90</y>
<width>178</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>Seat</string>
</property>
</widget>
<widget class="QCommandLinkButton" name="commandLinkButton_2">
<property name="geometry">
<rect>
<x>90</x>
<y>120</y>
<width>178</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>Seat Belt</string>
</property>
</widget>
<widget class="QCommandLinkButton" name="commandLinkButton_3">
<property name="geometry">
<rect>
<x>90</x>
<y>150</y>
<width>178</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>Air Bags</string>
</property>
</widget>
<widget class="QCommandLinkButton" name="commandLinkButton_4">
<property name="geometry">
<rect>
<x>90</x>
<y>180</y>
<width>178</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>Mirrors</string>
</property>
</widget>
<widget class="QCommandLinkButton" name="commandLinkButton_5">
<property name="geometry">
<rect>
<x>90</x>
<y>210</y>
<width>178</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>Storage Compartment</string>
</property>
</widget>
<widget class="QCommandLinkButton" name="commandLinkButton_6">
<property name="geometry">
<rect>
<x>90</x>
<y>240</y>
<width>178</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>Back</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
these are the 5 files where i have written the code. I want to connect my 1st UI screen which consists of the button "Car Internals" When i click on the "Car Internals button it shud go the next screen. i.e., screen2. Similarly I want to do foe all the buttons which i have shown in the mainwindow.ui file.
Please help...
Thank You Sir/Ma'am.