Seite 1 von 1

stachedwidget und next button bei einem wizard dialog

Verfasst: 15. März 2007 01:06
von defenderLQ
hi

ich wollte mal ein wizard dialog erstellen nun klappt vorwärts und rückwärts
aber es geht nur nach der reihe nach..

wenn ich also

wenn ein radiobutton gechecked ist ,dann klick ich auf next,dann soll es mir das gewünschte
stackedwidget page anzeigen...

wie geht das?kann mir jemand helfen?

Code: Alles auswählen

include "AddFriendWizard.h"
#include <sstream>

#include <QContextMenuEvent>
#include <QMenu>
#include <QCursor>
#include <QPoint>
#include <QMouseEvent>
#include <QPixmap>

/** Constructor */
AddFriendWizard::AddFriendWizard(QWidget *parent, Qt::WFlags flags)
: QDialog(parent, flags)
{
  /* Invoke the Qt Designer generated object setup routine */
  ui.setupUi(this);
  
  //GConfig config;
  //config.loadWidgetInformation(this);

  // connect up the buttons.
  //connect( ui.cancelButton, SIGNAL( clicked ( bool ) ), this, SLOT( cancelChan( ) ) );
  //connect( ui.createButton, SIGNAL( clicked ( bool ) ), this, SLOT( createChan( ) ) );

    setFixedSize(QSize(508, 312));

  /* Hide platform specific features */
#ifdef Q_WS_WIN

#endif
}




void AddFriendWizard::on_nextButton_clicked()
{
    // The current index position
    int index = ui.textstackedWidget->currentIndex();
    // Test the different widgets
    switch ( ui.textstackedWidget->currentIndex()) {
        // Firewall buttons
        case 1 : 
        {
            if ( ui.keyradioButton->isChecked() )
            {

                break;
            }
            if ( ui.pqipemradioButton->isChecked() )
            {
     
                break;
            }
            break;
        }
       
    }

    /*
    * move to the next widget, with the signal/slot also labelstackedWidget,
    * it's also moved
    */
    index++;
    // activate the backButton, because we are at the second widget or higher
    ui.backButton->setEnabled(true);

    // if lastStep is true, then we clicked the finish button	
    if ( lastStep )
    {   

        // leave the dialog
        accept();
    }

    /* 
    * if we are at the last widget or higher
    * the >= is here because the button "Next" becomes the button "Finish" there
    */
    if ( index >= ui.textstackedWidget->count() - 1 )
    {
        // the widget position is set to the last widget
        index = ui.textstackedWidget->count() - 1;
        // the button "Next" gets a new text: "Finish"
        ui.nextButton->setText(tr("Finish"));
        // we are at the last step, so we can finish here
        lastStep = true;
    }
    else
    {
        lastStep = false;
    }
    
    ui.textstackedWidget->setCurrentIndex(index);
}


void AddFriendWizard::on_backButton_clicked()
{
    int index = ui.textstackedWidget->currentIndex() - 1;                                   
    if ( index <= 0 )
    {
        index = 0;
        ui.backButton->setEnabled(false);
    }
    ui.nextButton->setText(tr("Next"));
    lastStep = false;
    ui.textstackedWidget->setCurrentIndex(index);
}

/*!
* This function closes the dialog without saving the values
*/
void AddFriendWizard::on_cancelButton_clicked()
{
    // if cancel is pressed, use the standard settings
    //writeSettings();
    // leave but show that cancel was pressed
    reject();
}


also wenn

ui.keyradioButton->isChecked

dann soll per ui.nextbutton der gewünschte stackedwidget "page_2" angezeit werden

Verfasst: 15. März 2007 09:06
von upsala
Dann gib im Designer deinen einzelnen Seiten einen Namen und sag dann in deiner Funktion

Code: Alles auswählen

ui.textstackedWidget->setCurrentWidget(ui.seiteX);

Verfasst: 15. März 2007 13:58
von defenderLQ
habs nun so probiert es geht aber immer zum nächsten...

Code: Alles auswählen

void AddFriendWizard::on_nextButton_clicked()
{
    // The current index position
    int index = ui.textstackedWidget->currentIndex();
    // Test the different widgets
    switch ( ui.textstackedWidget->currentIndex()) {
        // Firewall buttons
        case 1 : 
        {
            if ( ui.keyradioButton->isChecked() )
            {
                ui.textstackedWidget->setCurrentWidget(ui.keypage); 
                break;
            }
            if ( ui.pqipemradioButton->isChecked() )
            {
                ui.textstackedWidget->setCurrentWidget(ui.pqipempage);
                break;
            }
            break;
        }
       
    }

Verfasst: 15. März 2007 18:52
von upsala
Tja, dann wirst du wohl die falschen Widgets angegeben haben.

Verfasst: 16. März 2007 09:17
von defenderLQ
kann man das ganze auch per Signal/Slot editor machen?
habs probiert aber das zeigt mir kein checked oder zum schluss
z.b. das keypage usw nicht an...

Verfasst: 16. März 2007 12:21
von upsala
Nein