⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qwizard.cpp

📁 Trolltech公司发布的图形界面操作系统。可在qt-embedded-2.3.10平台上编译为嵌入式图形界面操作系统。
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*!  Enables or disables the "Next" button for pages \a w in the wizard.  By default, all pages have this button.*/void QWizard::setNextEnabled( QWidget * w, bool enable ){    QWizardPrivate::Page * p = d->page( w );    if ( !p )	return;    p->nextEnabled = enable;    updateButtons();}/*!  Enables or disables the "Finish" button for pages \a w in the wizard.  By default, \e no pages have this button.*/void QWizard::setFinishEnabled( QWidget * w, bool enable ){    QWizardPrivate::Page * p = d->page( w );    if ( !p )	return;    p->finishEnabled = enable;    updateButtons();}/*!  Enables or disables the "Help" button for pages \a w in the wizard.  By default, all pages have this button.*/void QWizard::setHelpEnabled( QWidget * w, bool enable ){    QWizardPrivate::Page * p = d->page( w );    if ( !p )	return;    p->helpEnabled = enable;    updateButtons();}/*!  This virtual function returns TRUE if \a w is appropriate fordisplay in the current context of the wizard, and FALSE if QWizardshould go on.It is called when the Next button is clicked.\warning The last page of a wizard will be displayed if nothing else wantsto, and the Next button was enabled when the user clicked.The default implementation returns whatever was set usingsetAppropriate().  The ultimate default is TRUE.*/bool QWizard::appropriate( QWidget * w ) const{    QWizardPrivate::Page * p = d->page( w );    return p ? p->appropriate : TRUE;}/*!  Sets whether it is appropriate for \a w to be displayed in the  current context of the wizard.  \sa appropriate()*/void QWizard::setAppropriate( QWidget * w, bool enable ){    QWizardPrivate::Page * p = d->page( w );    if ( p )	p->appropriate = enable;}void QWizard::updateButtons(){    if ( !d->current )	return;    setBackEnabled( d->current->backEnabled && d->current->back != 0 );    setNextEnabled( d->current->nextEnabled );    d->finishButton->setEnabled( d->current->finishEnabled );    d->helpButton->setEnabled( d->current->helpEnabled );    if ( ( d->current->finishEnabled && !d->finishButton->isVisible() ) ||	 ( d->current->backEnabled && !d->backButton->isVisible() ) ||	 ( d->current->nextEnabled && !d->nextButton->isVisible() ) ||	 ( d->current->helpEnabled && !d->helpButton->isVisible() ) )	layOut();}/*!  Returns a pointer to the page currently being displayed by thewizard.  The wizard does its best to make sure that this value isnever 0, but if you try hard enough it can be.*/QWidget * QWizard::currentPage() const{    return d->ws->visibleWidget();}/*!  Returns the title of \a page.*/QString QWizard::title( QWidget * page ) const{    QWizardPrivate::Page * p = d->page( page );    return p ? p->t : QString::null;}/*!  Sets the title for the \a page to \a title.*/void QWizard::setTitle( QWidget *page, const QString &t ){    QWizardPrivate::Page * p = d->page( page );    if ( p )	p->t = t;    if ( page == currentPage() )	d->title->setText( t );	}/*!  Returns the Back button of the dialog.  By default, this button is connected to the back()  slot, which is virtual.*/QPushButton * QWizard::backButton() const{    return d->backButton;}/*!  Returns the Next button of the dialog.  By default, this button is connected to the next()  slot, which is virtual.*/QPushButton * QWizard::nextButton() const{    return d->nextButton;}/*!  Returns the Finish button of the dialog.  By default, this button is connected to the QDialog::accept() slot,  which is virtual so you may reimplement it in a QWizard subclass.*/QPushButton * QWizard::finishButton() const{    return d->finishButton;}/*!  Returns the Cancel button of the dialog.  By default, this button is connected to the QDialog::reject() slot,  which is virtual so you may reimplement it in a QWizard subclass.*/QPushButton * QWizard::cancelButton() const{    return d->cancelButton;}/*!  Returns the Help button of the dialog.  By default, this button is connected to the help() slot.*/QPushButton * QWizard::helpButton() const{    return d->helpButton;}/*!  This virtual function is responsible for adding the bottomdivider and buttons below it.\a layout is the vertical layout of the entire wizard.*/void QWizard::layOutButtonRow( QHBoxLayout * layout ){    bool hasHelp = FALSE;    bool hasEarlyFinish = FALSE;    int i = d->pages.size() - 2;    while ( !hasEarlyFinish && i >= 0 ) {	if ( d->pages[i] && d->pages[i]->finishEnabled )	    hasEarlyFinish = TRUE;	i--;    }    i = 0;    while ( !hasHelp && i < (int)d->pages.size() ) {	if ( d->pages[i] && d->pages[i]->helpEnabled )	    hasHelp = TRUE;	i++;    }    QBoxLayout * h = new QBoxLayout( QBoxLayout::LeftToRight );    layout->addLayout( h );    h->addWidget( d->cancelButton );    h->addStretch( 42 );    h->addWidget( d->backButton );    h->addSpacing( 6 );    if ( hasEarlyFinish ) {	d->nextButton->show();	d->finishButton->show();	h->addWidget( d->nextButton );	h->addSpacing( 12 );	h->addWidget( d->finishButton );    } else if ( d->pages.size() == 0 ||		d->current->finishEnabled ||		d->current == d->pages[d->pages.size()-1] ) {	d->nextButton->hide();	d->finishButton->show();	h->addWidget( d->finishButton );    } else {	d->nextButton->show();	d->finishButton->hide();	h->addWidget( d->nextButton );    }    // if last page is disabled - show finished btn. at lastpage-1    i = d->pages.count()-1;    if ( i >= 0 && !appropriate( d->pages.at( i )->w ) &&	 d->current == d->pages.at( d->pages.count()-2 ) ) {	d->nextButton->hide();	d->finishButton->show();	h->addWidget( d->finishButton );    }    if ( hasHelp ) {        h->addSpacing( 12 );        h->addWidget( d->helpButton );    } else {        d->helpButton->hide();    }}/*!  This virtual function is responsible for laying out the title rowand adding the vertical divider between the title and the wizard page.\a layout is the vertical layout for the wizard, \a title is the titlefor this page, and this function is called every time \a titlechanges.*/void QWizard::layOutTitleRow( QHBoxLayout * layout, const QString & title ){    if ( !d->title )	d->title = new QLabel( this );    d->title->setText( title );    layout->addWidget( d->title, 10 );    d->title->repaint();}/**/void QWizard::layOut(){    delete d->v;    d->v = new QVBoxLayout( this, 6, 0, "top-level layout" ); // No tr    QHBoxLayout * l;    l = new QHBoxLayout( 6 );    d->v->addLayout( l, 0 );    layOutTitleRow( l, d->current ? d->current->t : QString::null );    if ( ! d->hbar1 ) {	d->hbar1 = new QFrame( this, "<hr>", 0, TRUE );	d->hbar1->setFrameStyle( QFrame::Sunken + QFrame::HLine );	d->hbar1->setFixedHeight( 12 );    }    d->v->addWidget( d->hbar1 );    d->v->addWidget( d->ws, 10 );    if ( ! d->hbar2 ) {	d->hbar2 = new QFrame( this, "<hr>", 0, TRUE );	d->hbar2->setFrameStyle( QFrame::Sunken + QFrame::HLine );	d->hbar2->setFixedHeight( 12 );    }    d->v->addWidget( d->hbar2 );    l = new QHBoxLayout( 6 );    d->v->addLayout( l );    layOutButtonRow( l );    d->v->activate();}/*! \reimp */bool QWizard::eventFilter( QObject * o, QEvent * e ){    if ( o == d->ws && e && e->type() == QEvent::ChildRemoved ) {	QChildEvent * c = (QChildEvent*)e;	if ( c->child() && c->child()->isWidgetType() )	    removePage( (QWidget *)c->child() );    }    return QDialog::eventFilter( o, e );}/*!  Removes \a page from this wizard.  Does not delete  \a page. If \a page is currently being displayed, QWizard will  display something else.*/void QWizard::removePage( QWidget * page ){    if ( !page )	return;    int i = d->pages.size();    while( --i >= 0 && d->pages[i] && d->pages[i]->w != page ) { }    if ( i < 0 )	return;    d->pages.remove( i );    for ( uint j = i; j < d->pages.size() - 1; ++j )	d->pages.insert( j, d->pages.take( j + 1 ) );    d->pages.resize( d->pages.size() - 1 );    d->ws->removeWidget( page );    if ( pageCount() > 0 )	showPage( QWizard::page( 0 ) );}/*!  Returns a pointer to page a position \a pos, or 0 if \a pos is out of range.  The first page has position 0.*/QWidget* QWizard::page( int pos ) const{    if ( pos >= pageCount() || pos < 0 )      return 0;    return d->pages[ pos ]->w;}#endif // QT_NO_WIZARD_IMPL#endif // QT_NO_WIZARD

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -