示例#1
0
文件: main.cpp 项目: clee/runcible
int main(int argc, char *argv[]) {
    QApplication app(argc, argv);

    QString filename("unknown");
    if (argc == 2) {
        filename = argv[1];
    }

    RWindow window;
    QBoxLayout *layout = qobject_cast<QBoxLayout *>(window.layout());

    QLabel heading("Could not open file.");
    heading.setFont(QFont("Liberation Serif", 30));
    layout->addWidget(&heading);

    layout->addStrut(8);

    QLabel detail(
        QString("The file %1 is of an unrecognized type and cannot be opened.")
        .arg(runcible::quote(filename)));
    detail.setFont(QFont("Liberation Serif", 12));
    detail.setWordWrap(true);
    layout->addWidget(&detail);

    layout->addStretch(1);

    QObject::connect(&window, SIGNAL(back()), &app, SLOT(quit()));

    window.showMessage("How unfortunate.");
    window.showMaximized();

    return app.exec();
}
示例#2
0
/*!
  Changes the status bar's appearance to account for item
  changes. Special subclasses may need this, but normally
  geometry management will take care of any necessary
  rearrangements.
*/
void QStatusBar::reformat()
{
    if ( d->box )
	delete d->box;

    QBoxLayout *vbox;
    if ( isSizeGripEnabled() ) {
	d->box = new QHBoxLayout( this );
	vbox = new QVBoxLayout( d->box );
    } else {
	vbox = d->box = new QVBoxLayout( this );
    }
    vbox->addSpacing( 3 );
    QBoxLayout* l = new QHBoxLayout( vbox );
    l->addSpacing( 3 );

    int maxH = fontMetrics().height();

    QStatusBarPrivate::SBItem* item = d->items.first();
    while ( item && !item->p ) {
	l->addWidget( item->w, item->s );
	l->addSpacing( 4 );
	int itemH = item->w->sizeHint().height();
	maxH = QMAX( maxH, itemH );
	item = d->items.next();
    }

    l->addStretch( 0 );

    while ( item ) {
	l->addWidget( item->w, item->s );
	l->addSpacing( 4 );
	int itemH = item->w->sizeHint().height();
	maxH = QMAX( maxH, itemH );
	item = d->items.next();
    }
#ifndef QT_NO_SIZEGRIP
    if ( d->resizer ) {
	maxH = QMAX( maxH, d->resizer->sizeHint().height() );
	d->box->addSpacing( 2 );
	d->box->addWidget( d->resizer, 0, AlignBottom );
    }
#endif
    l->addStrut( maxH );
    vbox->addSpacing( 2 );
    d->box->activate();
    repaint();
}
示例#3
0
void QBoxLayoutProto::addStrut(int size)
{
  QBoxLayout *item = qscriptvalue_cast<QBoxLayout*>(thisObject());
  if (item)
    item->addStrut(size);
}