Compare commits

...

2 Commits
v1.4 ... main

Author SHA1 Message Date
a86dfcfe97 新增-#5 添加删除行/列功能 2024-02-24 21:58:57 +08:00
5227ceaf5c 优化-最后一列多增加一个制表符 2024-02-22 22:32:13 +08:00
3 changed files with 26 additions and 3 deletions

View File

@ -52,14 +52,18 @@ MainWindow::MainWindow(QWidget *parent)
firstColMenu = new QMenu(this);
QAction* addRowAboveAction = firstColMenu->addAction(tr("↑ 向上添加一行"));
QAction* addRowBelowAction = firstColMenu->addAction(tr("向下添加一行 ↓"));
QAction* delRowAction = firstColMenu->addAction(tr("删除"));
connect(addRowAboveAction, &QAction::triggered, this, &MainWindow::onAddRowAboveActionTriggered);
connect(addRowBelowAction, &QAction::triggered, this, &MainWindow::onAddRowBelowActionTriggered);
connect(delRowAction, &QAction::triggered, this, &MainWindow::onDelRowActionTriggered);
firstRowMenu = new QMenu(this);
QAction* addColAboveAction = firstRowMenu->addAction(tr("← 向左添加一列"));
QAction* addColBelowAction = firstRowMenu->addAction(tr("向右添加一列 →"));
QAction* delColAction = firstRowMenu->addAction(tr("删除"));
connect(addColAboveAction, &QAction::triggered, this, &MainWindow::onAddColAboveActionTriggered);
connect(addColBelowAction, &QAction::triggered, this, &MainWindow::onAddColBelowActionTriggered);
connect(delColAction, &QAction::triggered, this, &MainWindow::onDelColActionTriggered);
}
@ -156,6 +160,20 @@ void MainWindow::onAddColBelowActionTriggered()
}
}
void MainWindow::onDelRowActionTriggered()
{
QTableWidget* tableWidget = ui->tableWidget;
int currentRow = tableWidget->currentRow();
tableWidget->removeRow(currentRow);
}
void MainWindow::onDelColActionTriggered()
{
QTableWidget* tableWidget = ui->tableWidget;
int currentColumn = tableWidget->currentColumn();
tableWidget->removeColumn(currentColumn);
}
void MainWindow::showProgressDialog(const QString& labelText, int minimum, int maximum)
{
progressDialog = new QProgressDialog(labelText, "Cancel", minimum, maximum, this);
@ -298,7 +316,7 @@ void MainWindow::onSaveButtonClicked()
out << "\t"; // 制表符分隔
}
}
out << "\t"; // 最后一列再加一个制表符,以防万一
out << "\r\n"; // 换行,注意使用\r\n表示换行符
}
@ -344,7 +362,7 @@ void MainWindow::onSaveAsButtonClicked()
out << "\t"; // 制表符分隔
}
}
out << "\t"; // 最后一列再加一个制表符,以防万一
out << "\r\n"; // 换行,注意使用\r\n表示换行符
}
@ -597,6 +615,7 @@ void MainWindow::convertSqliteToText()
if (i < record.count() - 1)
textStream << "\t";
}
textStream << "\t";
textStream << "\r\n";
++progress;

View File

@ -35,6 +35,8 @@ private slots:
void onAddRowBelowActionTriggered();
void onAddColAboveActionTriggered();
void onAddColBelowActionTriggered();
void onDelRowActionTriggered();
void onDelColActionTriggered();
private:
Ui::MainWindow *ui;

View File

@ -20,6 +20,9 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QTableWidget" name="tableWidget"/>
</item>
@ -46,7 +49,6 @@
</widget>
<addaction name="menuOpen"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<action name="actionOpen">
<property name="text">
<string>打开</string>