How to create back function using Qt



  • hai all...
    i have a problem when make a project for symbian mobile,
    can you give me source example about how to create back function, form to another form...
    thank you........



  • You have too many ways to make "back fuction" button. One of the easiest way is to use QStackedWidget and setting the index of each pages.



  • Or, perhaps, if your application is suitable for it, you could use [[doc:QWizard]] and [[doc:QWizardPage]]. This is designed for step-wise processes, including the ability to go back.



  • can you give me source example?



  • There is an example on wizards in the Qt documentation. Did you study that?



  • this is my source

    mainwindow.h
    @#ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QtGui/QMainWindow>
    #include <menuadm.h>
    #include <menuinform.h>
    #include <menubeli.h>
    #include <menubayar.h>
    #include <menutransfer.h>
    #include <promo.h>

    namespace Ui {
    class MainWindow;
    }

    class MainWindow : public QMainWindow
    {
    Q_OBJECT
    public:
    enum ScreenOrientation {
    ScreenOrientationLockPortrait,
    ScreenOrientationLockLandscape,
    ScreenOrientationAuto
    };

    explicit MainWindow(QWidget *parent = 0);
        MenuAdm *objmain1;
        MenuInform *objmain2;
        MenuBeli *objmain3;
        MenuBayar *objmain4;
        MenuTransfer *objmain5;
        Promo *objmain6;
    
    virtual ~MainWindow();
    
    void setOrientation(ScreenOrientation orientation);
    void showExpanded();
    

    private slots:
    void btnaction();
    void btnaction1();
    void btnaction2();
    void btnaction3();
    void btnaction4();
    void btnaction5();

    private:
    Ui::MainWindow *ui;

    };

    #endif // MAINWINDOW_H@

    mainwindow.cpp
    @
    #include "mainwindow.h"
    #include "ui_mainwindow.h"

    #include <QtCore/QCoreApplication>

    MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    connect(ui->pushButton,SIGNAL(clicked()),this,SLOT(btnaction()));
    connect(ui->pushButtonInf,SIGNAL(clicked()),this,SLOT(btnaction1()));
    connect(ui->pushButtonBeli,SIGNAL(clicked()),this,SLOT(btnaction2()));
    connect(ui->pushButtonBayar,SIGNAL(clicked()),this,SLOT(btnaction3()));
    connect(ui->pushButtonTransfer,SIGNAL(clicked()),this,SLOT(btnaction4()));
    connect(ui->pushButtonPromo,SIGNAL(clicked()),this,SLOT(btnaction5()));

    }
    void MainWindow::btnaction()
    {
    objmain1 = new MenuAdm;
    objmain1->showFullScreen(); //opening form kedua
    }
    void MainWindow::btnaction1()
    {
    objmain2 = new MenuInform;
    objmain2->showFullScreen();
    }
    void MainWindow::btnaction2()
    {
    objmain3 = new MenuBeli;
    objmain3->showFullScreen();
    }
    void MainWindow::btnaction3()
    {
    objmain4 = new MenuBayar;
    objmain4->showFullScreen();
    }
    void MainWindow::btnaction4()
    {
    objmain5 = new MenuTransfer;
    objmain5->showFullScreen();
    }
    void MainWindow::btnaction5()
    {
    objmain6 = new Promo;
    objmain6->showFullScreen();
    }
    MainWindow::~MainWindow()
    {
    delete ui;
    }@

    menuadm.h
    @#ifndef MENUADM_H
    #define MENUADM_H

    #include <QMainWindow>
    #include <menudaftar.h>
    #include <menugantipin.h>

    namespace Ui {
    class MenuAdm;
    }

    class MenuAdm : public QMainWindow
    {
    Q_OBJECT

    public:
    explicit MenuAdm(QWidget *parent = 0);
    MenuDaftar *objmain7;
    MenuGantiPin *objmain8;

    ~MenuAdm();
    

    private slots:
    void btnaction6();
    void btnaction7();
    void btnaction8();

    private:
    Ui::MenuAdm *ui;
    };

    #endif // MENUADM_H
    @

    menuadm.cpp
    @#include "menuadm.h"
    #include "ui_menuadm.h"

    MenuAdm::MenuAdm(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MenuAdm)
    {
    ui->setupUi(this);
    connect(ui->pushButtonDaftar,SIGNAL(clicked()),this,SLOT(btnaction6()));
    connect(ui->pushButtonPin,SIGNAL(clicked()),this,SLOT(btnaction7()));
    }

    void MenuAdm::btnaction6()
    {
        objmain7 = new MenuDaftar;
        objmain7->showFullScreen();
    }
    void MenuAdm::btnaction7()
    {
        objmain8 = new MenuGantiPin;
        objmain8->showFullScreen();
    }
    

    MenuAdm::~MenuAdm()
    {
    delete ui;
    }
    @

    what should i do?
    i want create a function back push button in menuadm.ui,
    when the push button clicked, i can return to mainwindow.ui....
    help me,
    thanks



  • hei all,
    anybody can help?
    thanks...



  • You got tips, do something completely different, dump a large piece of code without explaining what that code is supposed to do, and then ask for comments... That simply isn't an effective way to solicit help.

    Read Eric Steven Raymonds "article on how to ask questions":http://www.catb.org/~esr/faqs/smart-questions.html if you don't understand the above.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.