本文整理汇总了C++中QTableWidget::setWindowTitle方法的典型用法代码示例。如果您正苦于以下问题:C++ QTableWidget::setWindowTitle方法的具体用法?C++ QTableWidget::setWindowTitle怎么用?C++ QTableWidget::setWindowTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTableWidget
的用法示例。
在下文中一共展示了QTableWidget::setWindowTitle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc,char* argv[])
{
QApplication app(argc,argv);
QTableWidget* table = new QTableWidget();
table->setWindowTitle("Connect to Mysql Database Example");
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("192.168.11.3");
db.setDatabaseName("menudb");
db.setUserName("root");
db.setPassword("test");
if (!db.open())
{
QMessageBox::critical(0, QObject::tr("Database Error"),
db.lastError().text());
}
QSqlQuery query("SELECT * FROM test");
table->setColumnCount(query.record().count());
table->setRowCount(query.size());
int index=0;
while (query.next())
{
table->setItem(index,0,new QTableWidgetItem(query.value(0).toString()));
table->setItem(index,1,new QTableWidgetItem(query.value(1).toString()));
index++;
}
table->show();
return app.exec();
}
示例2: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
const int n = 3;
QTableWidget *mainTable = new QTableWidget(n,n);
QTableWidgetItem *widgetItem = 0;
QStringList nameItems;
nameItems << "First" << "Second" << "Third";
mainTable->setHorizontalHeaderLabels(nameItems); //set headers on Horizontal
mainTable->setVerticalHeaderLabels(nameItems); //set headers on Vertical
for(int i = 0; i < n; ++i)
{
for(int j = 0; j < n; ++j)
{
widgetItem = new QTableWidgetItem(QString("%1,%2").arg(i).arg(j));
mainTable->setItem(i,j,widgetItem);
}
}
mainTable->setGeometry(430,340,400,180);
mainTable->setWindowTitle("Main table");
mainTable->show();
return a.exec();
}
示例3: showTable
void MainWindow::showTable()
{
QTextCursor cursor = editor->textCursor();
QTextTable *table = cursor.currentTable();
if (!table)
return;
QTableWidget *tableWidget = new QTableWidget(table->rows(), table->columns());
//! [9]
for (int row = 0; row < table->rows(); ++row) {
for (int column = 0; column < table->columns(); ++column) {
QTextTableCell tableCell = table->cellAt(row, column);
//! [9]
QTextFrame::iterator it;
QString text;
for (it = tableCell.begin(); !(it.atEnd()); ++it) {
QTextBlock childBlock = it.currentBlock();
if (childBlock.isValid())
text += childBlock.text();
}
QTableWidgetItem *newItem = new QTableWidgetItem(text);
tableWidget->setItem(row, column, newItem);
/*
//! [10]
processTableCell(tableCell);
//! [10]
*/
//! [11]
}
//! [11] //! [12]
}
//! [12]
tableWidget->setWindowTitle(tr("Table Contents"));
tableWidget->show();
}