当前位置: 首页>>代码示例>>C++>>正文


C++ QDockWidget::resize方法代码示例

本文整理汇总了C++中QDockWidget::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ QDockWidget::resize方法的具体用法?C++ QDockWidget::resize怎么用?C++ QDockWidget::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QDockWidget的用法示例。


在下文中一共展示了QDockWidget::resize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loadFile

bool MainWindowImpl::loadFile( QFileInfo const & fi )
{
    if( ! fi.isFile() ) return false;
	// FIXME: this dispatch needs to be generalized.
	QString fn( fi.filePath() ); // fi.absoluteFilePath() );
	bool worked = false;
	if( impl->gstate.board().fileNameMatches(fn) )
	{
		worked = impl->gstate.board().s11nLoad(fn);
	}
	else if( impl->gstate.fileNameMatches(fn) )
	{
		worked = this->loadGame(fn);
	}
	else if( fn.endsWith(".wiki") )
	{
	    worked = true;
	    QString lbl = QString("Wiki: %1").arg(fi.fileName());
	    QDockWidget * win = new QDockWidget( lbl, this );
	    qboard::WikiLiteView * v = new qboard::WikiLiteView;
	    win->setAttribute(Qt::WA_DeleteOnClose);
	    win->setWidget( v );
	    win->move( impl->gv->viewport()->mapToGlobal(QPoint(0,0)) );
	    win->resize( impl->gv->viewport()->size() );
	    win->setFloating(true);
	    this->addDockWidget(Qt::RightDockWidgetArea, win );
	    v->parseFile(fn);
	    win->setWindowTitle( v->windowTitle() );
	}
	else if( QRegExp("\\.[jq]s$",Qt::CaseInsensitive).indexIn(fn) > 0 )
	{
	    QScriptEngine & js( impl->gstate.jsEngine() );
	    qDebug() << "[ running script"<<fn<<"]";
	    QScriptValue rv = qboard::jsInclude( &js, fn );
	    if( rv.isError() )
	    {
		QStringList bt( js.uncaughtExceptionBacktrace() );
		QScriptValue exv = rv.isError() ? rv : js.uncaughtException();
		QString msg("Script threw or returned an exception:\n");
		msg += exv.toString()
		    + "\nBacktrace:\n"
		    + bt.join("\n");
		QMessageBox::warning( this, "JavaScript Exception",
				      msg,
				      QMessageBox::Ok, QMessageBox::Ok );
		worked = false;
	    }
	    else
	    {
		worked = true;
	    }
	    qDebug() << "[ done running script"<<fn<<"]";
	}
	else if( QRegExp("\\.(html|txt)$",Qt::CaseInsensitive).indexIn(fn) > 0 )
	{
#if QT_VERSION >= 0x040400
		QBoardDocsBrowser * b = new QBoardDocsBrowser;
		b->setHome(fn);
		b->setWindowTitle(fn);
		b->show();
		worked = true;
#else
		QMessageBox::warning( this, "Not implemented!",
				      "MainWindowImpl::loadFile(*.{txt,html}) not implemented for Qt < 4.4",
				      QMessageBox::Ok, QMessageBox::Ok );
		worked = false;
#endif
	}
	else if( QRegExp("\\.(png|jpg|gif|xpm|svg|bmp)$",Qt::CaseInsensitive).indexIn(fn) > 0 )
	{ // ^^^ FIXME: get the list of image formats from somewhere dynamic
		const size_t threshold = 10 * 1024;
		// ^^^ fixme: ^^^^ do this based on image resolution, not file size, cuz many
		// large-sized PNGs are quite small.
		if( fi.size() < threshold )
		{
			worked = this->loadPiece(fi);
		}
		else
		{
			worked = this->impl->gstate.board().s11nLoad(fn); // fi.absoluteFilePath());
		}
	}
	if( worked )
	{
		this->statusBar()->showMessage("Loaded: "+fn); // fi.absoluteFilePath());
	}
	else
	{
		this->statusBar()->showMessage("Load FAILED: "+fn); // fi.absoluteFilePath());
	}
	return worked;
}
开发者ID:SashaIliyn,项目名称:GUI-Project,代码行数:92,代码来源:MainWindowImpl.cpp

示例2: createWidget

QWidget* WidgetStyle::createWidget(const QString& name)
{
    if(name == "CheckBox")
    {
        QCheckBox* box = new QCheckBox("CheckBox");
        box->setObjectName("CheckBox");
        return setLayoutWidget({ box }, { 100, 30 });
    }
    else if(name == "ComboBox")
    {
        QComboBox* box = new QComboBox;
        box->addItem("Item1");
        box->addItem("Item3");
        box->addItem("Item3");
        box->setObjectName("ComboBox");
        return setLayoutWidget({ box }, { 70, 30 });
    }
    else if(name == "DateEdit")
    {
        QDateEdit* date = new QDateEdit;
        date->setObjectName("DateEdit");
        return setLayoutWidget({ date }, { 110, 40 });
    }
    else if(name == "DateTimeEdit")
    {
        QDateTimeEdit* date = new QDateTimeEdit;
        date->setObjectName("DateTimeEdit");
        return setLayoutWidget({ date }, { 160, 30 });
    }
    else if(name == "Dialog")
    {
        QDialog* dialog = new QDialog;
        dialog->setObjectName("Dialog");
        return setLayoutWidget({ dialog }, { 160, 110 });
    }
    else if(name == "DockWidget") //?
    {
        QDockWidget* widget = new QDockWidget;
        widget->setObjectName("DockWidget");
        widget->resize(61, 22);
        return widget;
    }
    else if(name == "DoubleSpinBox")
    {
        QDoubleSpinBox* box = new QDoubleSpinBox;
        box->setObjectName("DoubleSpinBox");
        return setLayoutWidget({ box }, { 90, 40 });
    }
    else if(name == "Frame") //??
    {
        QFrame* frame = new QFrame;
        frame->setObjectName("Frame");
        frame->resize(150, 100);
        return frame;
    }
    else if(name == "GroupBox")
    {
        QGroupBox* box = new QGroupBox("GroupBox");
        box->setObjectName("GroupBox");
        return setLayoutWidget({ box }, { 160, 110 });
    }
    else if(name == "Label")
    {
        QLabel* label = new QLabel("Label");
        label->setObjectName("Label");
        return setLayoutWidget({ label }, { 40, 20});
    }
    else if(name == "LineEdit")
    {
        QLineEdit* line = new QLineEdit;
        line->setObjectName("LineEdit");
        return setLayoutWidget({ line }, { 30, 30 });
    }
    else if(name == "ListView") //??
    {
        QListView* view = new QListView;
        view->setObjectName("ListView");
        view->resize(71, 71);
        return view;
    }
    else if(name == "ListWidget")
    {
        QListWidget* list = new QListWidget;
        list->setObjectName("ListWidget");
        for(int i = 0; i < 20; i++)
            list->addItem(QString("Item %1").arg(i));
        return setLayoutWidget({ list }, { 80, 80 });
    }
    else if(name == "MainWindow")
    {
        QMainWindow* window = new QMainWindow;
        window->setObjectName("MainWindow");
        return setLayoutWidget({ window }, { 160, 110 });
    }
    else if(name == "Menu")
    {
        QMenu* parentMenu = new QMenu;
        parentMenu->setObjectName("Menu");
        parentMenu->addMenu("Menu1");
        QMenu* menu1 = parentMenu->addMenu("Menu2");
//.........这里部分代码省略.........
开发者ID:kissofblood,项目名称:September,代码行数:101,代码来源:widgetstyle.cpp


注:本文中的QDockWidget::resize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。