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


C++ QTableWidgetItem::setSizeHint方法代码示例

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


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

示例1: setSizeHint

 int TableWidgetItem::setSizeHint( lua_State * L )// ( const QSize & size )void
 {
	 QTableWidgetItem* lhs = ValueInstaller2<QTableWidgetItem>::check( L, 1 );
	 QSize* size = ValueInstaller2<QSize>::check( L, 2 );
	 lhs->setSizeHint( *size );
	 return 0;
 }
开发者ID:Wushaowei001,项目名称:NAF,代码行数:7,代码来源:QtlTableWidgetItem.cpp

示例2: QTableWidget

lmcImagePicker::lmcImagePicker(
        QWidget *parent,
        QList<QString>* source,
        int picSize,
        int columns,
        int* selected,
        int actionIndex )
    : QTableWidget(parent)
{
	setMouseTracking(true);

	setBackgroundRole(QPalette::Window);
	setIconSize(QSize(picSize, picSize));
	setFrameShape(QFrame::NoFrame);
	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	setEditTriggers(QAbstractItemView::NoEditTriggers);
	setSelectionMode(QAbstractItemView::NoSelection);
	setShowGrid(false);
	horizontalHeader()->setVisible(false);
	verticalHeader()->setVisible(false);
	setStyleSheet("QTableWidget { padding: 4px }");	// padding around table

	max_col = columns;
	int max_row = qCeil(source->count() / (qreal)max_col);

	setColumnCount(max_col);
	setRowCount(max_row);

	int cellSize = picSize + 8;
	verticalHeader()->setDefaultSectionSize(cellSize);
	verticalHeader()->setMinimumSectionSize(cellSize);
	horizontalHeader()->setDefaultSectionSize(cellSize);
	horizontalHeader()->setMinimumSectionSize(cellSize);

	//	set min and max size of table, with padding included
	setMinimumSize(max_col * cellSize + 8, max_row * cellSize + 8);
	setMaximumSize(max_col * cellSize + 8, max_row * cellSize + 8);

	for(int i = 0; i < max_row; i++) {
		for(int j = 0; j < max_col; j++) {
			int k = (i * max_col) + j;

			QTableWidgetItem* item = new QTableWidgetItem();
			item->setData(TypeRole, 0);
			if(k < source->count()) {
				item->setIcon(QIcon(source->value(k)));
				item->setData(TypeRole, 1);
				item->setSizeHint(QSize(picSize, picSize));
				item->setBackground(this->palette().window());
			}
			setItem(i, j, item);
		}
	}

	this->actionIndex = actionIndex;
	this->selected = selected;
	this->hoverItem = NULL;
}
开发者ID:sonic414,项目名称:lmc-clone,代码行数:59,代码来源:imagepicker.cpp

示例3: setupListGroup

/**
 * Sets up the list group.
 * @param margin  The margin of the group.
 */
void ClassifierListTab::setupListGroup(int margin)
{
    QString typeName;
    QString newItemType;

    switch (m_itemType) {
    case ot_Attribute: {
        typeName = i18n("Attributes");
        m_centralTableTW->setColumnCount(7);
        m_centralTableTW->setHorizontalHeaderItem(0,new QTableWidgetItem("Name"));
        m_centralTableTW->setHorizontalHeaderItem(1,new QTableWidgetItem("Type"));
        m_centralTableTW->setHorizontalHeaderItem(2,new QTableWidgetItem("Initial value"));
        m_centralTableTW->setHorizontalHeaderItem(3,new QTableWidgetItem("Visibility"));
        m_centralTableTW->setHorizontalHeaderItem(4,new QTableWidgetItem("Stereotype name"));
        QTableWidgetItem* stat = new QTableWidgetItem("S");
        stat->setToolTip("Static");
        m_centralTableTW->setHorizontalHeaderItem(5,stat);
        QTableWidgetItem* doc = new QTableWidgetItem("Doc");
        doc->setToolTip("Documentation");
        m_centralTableTW->setHorizontalHeaderItem(6,doc);
      }
      break;
    case ot_Operation: {
        typeName = i18n("Operations");
        m_centralTableTW->setColumnCount(10);
        m_centralTableTW->setHorizontalHeaderItem(0,new QTableWidgetItem("Name"));
        QTableWidgetItem* param = new QTableWidgetItem("Parameters");
        param->setSizeHint(QSize(0,0));
        m_centralTableTW->setHorizontalHeaderItem(1,param);
        m_centralTableTW->setHorizontalHeaderItem(2,new QTableWidgetItem("Type"));
        m_centralTableTW->setHorizontalHeaderItem(3,new QTableWidgetItem("Visibility"));
        m_centralTableTW->setHorizontalHeaderItem(4,new QTableWidgetItem("Stereotype"));
        QTableWidgetItem* stat = new QTableWidgetItem("S");
        stat->setToolTip("Static");
        m_centralTableTW->setHorizontalHeaderItem(5,stat);
        QTableWidgetItem* abs = new QTableWidgetItem("A");
        abs->setToolTip("Abstract");
        m_centralTableTW->setHorizontalHeaderItem(6,abs);
        QTableWidgetItem* cons = new QTableWidgetItem("C");
        cons->setToolTip("Const");
        m_centralTableTW->setHorizontalHeaderItem(7,cons);
        QTableWidgetItem* doc = new QTableWidgetItem("Doc");
        doc->setToolTip("Documentation");
        m_centralTableTW->setHorizontalHeaderItem(8,doc);
        m_centralTableTW->setHorizontalHeaderItem(9,new QTableWidgetItem("Source code"));
      }
      break;
    case ot_Template:
        typeName = i18n("Templates");
        m_centralTableTW->setColumnCount(3);
        m_centralTableTW->setHorizontalHeaderItem(0,new QTableWidgetItem("Name"));
        m_centralTableTW->setHorizontalHeaderItem(1,new QTableWidgetItem("Type"));
        m_centralTableTW->setHorizontalHeaderItem(2,new QTableWidgetItem("Stereotype"));
        break;
    case ot_EnumLiteral:
        typeName = i18n("Enum Literals");
        m_centralTableTW->setColumnCount(2);
        m_centralTableTW->setHorizontalHeaderItem(0,new QTableWidgetItem("Name"));
        m_centralTableTW->setHorizontalHeaderItem(1,new QTableWidgetItem("Default Value"));
        break;
    case ot_EntityAttribute: {
        typeName = i18n("Entity Attributes");
        newItemType = i18n("N&ew Entity Attribute...");
        m_centralTableTW->setHorizontalHeaderItem(0,new QTableWidgetItem("Name"));
        m_centralTableTW->setHorizontalHeaderItem(1,new QTableWidgetItem("Type"));
        m_centralTableTW->setHorizontalHeaderItem(2,new QTableWidgetItem("Default Value"));
        m_centralTableTW->setHorizontalHeaderItem(3,new QTableWidgetItem("Stereotype"));
        m_centralTableTW->setHorizontalHeaderItem(4,new QTableWidgetItem("Length"));
        m_centralTableTW->setHorizontalHeaderItem(5,new QTableWidgetItem("Attributes"));
        QTableWidgetItem* autoI = new QTableWidgetItem("A");
        autoI->setToolTip("Auto Increment");
        m_centralTableTW->setHorizontalHeaderItem(6,autoI);
        QTableWidgetItem* allowNull = new QTableWidgetItem("N");
        allowNull->setToolTip("Allow null");
        m_centralTableTW->setHorizontalHeaderItem(7,allowNull);
        QTableWidgetItem* index = new QTableWidgetItem("I");
        index->setToolTip("Index");
        m_centralTableTW->setHorizontalHeaderItem(8,index);
        QTableWidgetItem* doc = new QTableWidgetItem("Doc");
        doc->setToolTip("Documentation");
        m_centralTableTW->setHorizontalHeaderItem(9,doc);
      }
        break;
    case ot_EntityConstraint:
        typeName = i18n( "Constraints" );
        newItemType = i18n( "N&ew Constraint..." );
        break;
    default:
        uWarning() << "unknown listItem type in ClassifierListTab";
        break;
    }

    m_centralTableTW->horizontalHeader()->setResizeMode(0,QHeaderView::Stretch);
    
    for (int i=1;i<12;i++) {
      m_centralTableTW->horizontalHeader()->setResizeMode(i,QHeaderView::ResizeToContents);
//.........这里部分代码省略.........
开发者ID:Elv13,项目名称:Umbrello-ng,代码行数:101,代码来源:classifierlisttab.cpp


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