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


C++ QTableWidget::setMaximumWidth方法代码示例

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


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

示例1: calcul_general

void FenPrincipale::calcul_general() {
	QString html = "<table>\n\t<thead>\n\t\t<tr>\n\t\t\t";
	html += "<td>"+tr("Position")+"</td>";
	html += "<td>"+tr("Équipage")+"</td>";
	html += "<td>"+tr("Points")+"</td>";
	for (int j = 0; j < this->nbManches; ++j) {
		html += "<td>"+tr("M")+QString::number(j+1)+"</td>";
	}
	html += "\n\t\t</tr>\n\t</thead>\n\t<tboby>";
	QTableWidget *table = new QTableWidget();
	table->verticalHeader()->hide();
	table->setSelectionMode(QAbstractItemView::NoSelection);
	table->setColumnCount(3+this->nbManches);
	table->setRowCount(this->nbEquipages);
	table->setColumnWidth(0, 80);
	table->setColumnWidth(1, 200);
	table->setColumnWidth(2, 60);
	int size = 80 + 200 + 60;
	QList<QString> labels;
	labels << tr("Position") << tr("Équipage") << tr("Points");
	for (int j = 0; j < this->nbManches; ++j) {
		labels << tr("M")+QString::number(j+1);
		size += 50;
		table->setColumnWidth(3+j, 50);
	}
	table->setMinimumWidth(size + 20);
	table->setMaximumWidth(size + 20);
	table->setHorizontalHeaderLabels(labels);
	ui->resultatsLayout->insertWidget(0, table);
	for (int i = 0; i < this->nbEquipages; ++i) {
		QList<int> ids;
		Equipage e1;
		for (int k = 0; k < this->nbEquipages; ++k) {
			Equipage e2 = this->equipages[k];
			if (e2.points <= 0) {
				// cet équipage a déjà été affiché
				continue;
			}
			if (ids.isEmpty() || e2.points < e1.points) {
				ids.clear();
				ids.append(k);
				e1 = e2;
			}
			else if (e2.points == e1.points) {
				// égalité de points
				// pour départager les équipages, on confronte leurs meilleures
				// manches (sans celles retirées)
				for (int j = 0; j < e1.pointsTries.size(); ++j) {
					if (e2.pointsTries[j] < e1.pointsTries[j]) {
						ids.clear();
						ids.append(k);
						e1 = e2;
						break;
					}
					else if (e2.pointsTries[j] > e1.pointsTries[j]) {
						break;
					}
					else if (j == e1.pointsTries.size()-1) {
						// égalité des manches
						// pour départager les équipages, on confronte toutes
						// leur manches dans l'ordre en partant de la dernière
						for (int l = 0; l < e1.pointsOrdonnes.size(); ++l) {
							if (e2.pointsOrdonnes[l] < e1.pointsOrdonnes[l]) {
								ids.clear();
								ids.append(k);
								e1 = e2;
								break;
							}
							else if (e2.pointsOrdonnes[l] > e1.pointsOrdonnes[l]) {
								break;
							}
							else if (l == e1.pointsOrdonnes.size()-1) {
								// égalité parfaite
								ids.append(k);
							}
						}
					}
				}
			}
		}
		for (int k = 0; k < ids.size(); ++k) {
			Equipage e = this->equipages[ids[k]];
			// on ajoute le début de la table html
			// on rajoute les manches en parallèle à causes de celles retirées
			QString nomString = "<span class=\"equipage\">"+e.nom+"</span>";
			if (this->typeClmt == CLMT_TEMPS) {
				nomString += "<span class=\"bateau\">"
					+this->bateaux.value(e.rating.toUpper()).serie
					+" ("+QString::number(e.coef)+")</span>";
			}
			html += "\n\t\t<tr>\n\t\t\t<td>"+QString::number(i+1)+"</td>"
				+"<td>"+nomString+"</td>"
				+"<td>"+QString::number(e.points)+"</td>";
			// on ajout l'équipage
			QLabel *pos = new QLabel(QString::number(i+1));
			QWidget *nomWidget = new QWidget();
			QVBoxLayout *nomLayout = new QVBoxLayout();
			QLabel *nom = new QLabel(e.nom);
			nom->setProperty("label", "nom");
			nomLayout->addWidget(nom);
//.........这里部分代码省略.........
开发者ID:piero-la-lune,项目名称:DeriVoile-calc,代码行数:101,代码来源:Step5.cpp

示例2: calcul_manches

void FenPrincipale::calcul_manches() {
	for (int j = 0;  j < this->nbManches; ++j) {
			// on initialise la table html pour l'export
		QString html = "<table>\n\t<thead>\n\t\t<tr>\n\t\t\t";
		html += "<td>"+tr("Place")+"</td>";
		html += "<td>"+tr("Équipage")+"</td>";
		html += "<td>"+tr("Points")+"</td>";
		if (this->typeClmt == CLMT_TEMPS) {
			html += "<td>"+tr("Temps réel")+"</td><td>"+tr("Temps compensé")+"</td>";
		}
		html += "\n\t\t</tr>\n\t</thead>\n\t<tboby>";
			// on affiche la table qui va contenir les résultats de la manche
		QTableWidget *table = new QTableWidget();
		table->verticalHeader()->hide();
		table->setSelectionMode(QAbstractItemView::NoSelection);
		table->setProperty("table", "manches");
		QList<QString> labels;
		labels << tr("Place") << tr("Équipage") << tr("Points");
		if (this->typeClmt == CLMT_TEMPS) {
			table->setColumnCount(5);
			labels << tr("Temps réel") << tr("Temps compensé");
			table->setMaximumWidth(560 + 20);
			table->setMinimumWidth(560 + 20);
			table->setColumnWidth(3, 120);
			table->setColumnWidth(4, 120);
		}
		else {
			table->setColumnCount(3);
			table->setMaximumWidth(320 + 20);
			table->setMinimumWidth(320 + 20);
		}
		table->setColumnWidth(0, 60);
		table->setColumnWidth(1, 200);
		table->setColumnWidth(2, 60);
		table->setHorizontalHeaderLabels(labels);
		table->setRowCount(this->nbEquipages);
		ui->choisirResultat->insertItem(j+1,
			tr("Résultats de la manche %1").arg(QString::number(j+1)));
		int nbAffiches = 0; // pour savoir à quelle ligne on en est
			// on traite et affiche les équipages
		// on traite chaque manche pour attribuer les points aux équipages
		for (int i = 0; i < this->nbEquipages; ++i) {
			// on recherche tous les équipages non encore traités pour cette
			// manches qui ont un tpsCompense minimal
			int min = 0;
			QList<int> ids;
			for (int k = 0; k < this->nbEquipages; ++k) {
				Manche m = this->equipages[k].manches[j];
				if (m.tpsCompense < 0 || m.points > 0 ) {
					// cet équipage a déjà été traité ou n'a pas de place/temps
					// (DNF, DNS, OCS, ...)
					continue;
				}
				if (m.tpsCompense < min || min == 0) {
					min = m.tpsCompense;
					ids.clear();
					ids.append(k);
				}
				else if (m.tpsCompense == min) {
					ids.append(k);
				}
			}
			if (min == 0) {
				// on n'a pas trouvé d'équipage à traiter (se produit s'il y a
				// des équipages DNS, DNF, OCS, ...)
				break;
			}
			for (int l = 0; l < ids.size(); ++l) {
				double points = (ids.size()-1.0)/2.0+i+1.0;
				this->equipages[ids.at(l)].points += points;
				this->equipages[ids.at(l)].pointsOrdonnes.prepend(points);
				this->equipages[ids.at(l)].pointsTries.append(points);
				this->equipages[ids.at(l)].manches[j].points = points;
				// on affiche ces équipages
				Equipage e = this->equipages[ids.at(l)];
				Manche m = e.manches[j];
				QLabel *place = new QLabel(QString::number(i+1));
				table->setCellWidget(i+l, 0, place);
				QWidget *nomWidget = new QWidget();
				QVBoxLayout *nomLayout = new QVBoxLayout();
				QLabel *nom = new QLabel(e.nom);
				nom->setProperty("label", "nom");
				nomLayout->addWidget(nom);
				if (this->typeClmt == CLMT_TEMPS) {
					QLabel *bateau = new QLabel();
					bateau->setText(this->bateaux.value(e.rating.toUpper()).serie
						+" ("+QString::number(e.coef)+")");
					bateau->setProperty("label", "bateau");
					nomLayout->addWidget(bateau);
					table->setRowHeight(i+l, 45);
				}
				nomLayout->setContentsMargins(0, 0, 0, 0);
				nomLayout->setSpacing(0);
				nomWidget->setLayout(nomLayout);
				table->setCellWidget(i+l, 1, nomWidget);
				QLabel *pointsi = new QLabel(QString::number(m.points));
				table->setCellWidget(i+l, 2, pointsi);
				if (this->typeClmt == CLMT_TEMPS) {
					QLabel *tpsReel = new QLabel(this->formate_tps(m.tpsReel));
					table->setCellWidget(i+l, 3, tpsReel);
//.........这里部分代码省略.........
开发者ID:piero-la-lune,项目名称:DeriVoile-calc,代码行数:101,代码来源:Step5.cpp


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