Qt4:定義済みのダイアログを使う


Qt4:百の定石


  • カラーダイアログを使う。
    QColor c= Qt::lightGray ;
    QColor c = QColorDialog::getColor(c) ;
  • フォントダイアログを使う。
    bool ok = false ;
    QFont font = QFontDialog::getFont(&ok,
             QFont( "Helvetica [Cronyx]", 10 ), this );
    if ( ok ) {  //フォントが選ばれた } 
    else { //選ばれなかった   }
  • ディレクトリーを選択する。
    QString dir = QFileDialog::getExistingDirectory(this, 
         tr("Open Directory"),
         "/home",
         QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks) ;
  • Save As
    QString fn = QFileDialog::getSaveFileName(  this, 
             tr("sum.dat"), QString::null, 0L  );
    if ( !fn.isEmpty() ) {
  • 情報を伝える。
    QMessageBox::information( 0, "Command error", "Couldn't execute." );
  • 重大な情報を伝える。
    QMessageBox::critical( 0, "Application name here",
           QString("重大なエラーがおきました。 ") );
  • 警告を伝える。Retry を Ok Abort をCancel にもできる。
      switch( QMessageBox::warning( this, "Application name here",
           "Could not save the user preferences,?n"
           "because the disk is full. You can delete?n"
           "some files and press Retry, or you can?n"
           "abort the Save Preferences operation.",
           QMessageBox::Retry | QMessageBox::Default,
           QMessageBox::Abort | QMessageBox::Escape )) {
       case QMessageBox::Retry: // Retry clicked or Enter pressed
           // try again
           break;
       case QMessageBox::Abort: // Abort clicked or Escape pressed
           // abort
           break;
       }
  • aboutを表示する。
      QMessageBox::about( this, "About <Application>",
           "<Application> is a <one-paragraph blurb>?n?n"
           "Copyright 1991-2003 Such-and-such. "
           "<License words here.>?n?n"
           "For technical support, call 1234-56789 or see?n"
           "http://www.such-and-such.com/Application/?n" );
  • progressbar を表示する。
    QProgressDialog* pgbar = new QProgressDialog("now...", "Cancel",0, 100) ;
    pgbar->show() ;
    for (int i=0; i<101; i++) pgbar->setValue(i) ;

最新の20件

2020-12-25 2007-03-14 2006-10-30 2006-11-09 2007-03-14 2006-11-09 2006-11-10 2006-11-09 2008-05-20 2007-11-07 2007-11-01

今日の20件

  • counter: 706
  • today: 1
  • yesterday: 1
  • online: 1