#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QToolBar>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::ViewInit()
{
QToolBar *toolBar = new QToolBar(this);
addAction(toolBar->toggleViewAction()); // 添加工具栏
QAction *action01 = new QAction(toolBar);
toolBar->addAction(action01);
}
void MainWindow::on_treeWidget_customContextMenuRequested(const QPoint &pos)
{
}
void MainWindow::on_treeWidget_itemEntered(QTreeWidgetItem *item, int column)
{
qDebug() << " on_treeWidget_itemEntered() " << endl;
qDebug() << column << endl;
QString label = item->text(column); // 获取当前的项目标签
int row = ui->treeWidget->indexOfTopLevelItem(item); // 获取项目的行号
qDebug() << "Mouse entered on item:" << label << "in row:" << row << "out of:" << ui->treeWidget->topLevelItemCount() << "rows";
}
void MainWindow::on_treeWidget_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
{
qDebug() << " on_treeWidget_currentItemChanged() " << endl;
}
void MainWindow::on_treeWidget_itemActivated(QTreeWidgetItem *item, int column)
{
qDebug() << " on_treeWidget_itemActivated() " << endl;
}
void MainWindow::on_treeWidget_itemChanged(QTreeWidgetItem *item, int column)
{
qDebug() << " on_treeWidget_itemChanged() " << endl;
}
void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, int column)
{
qDebug() << " on_treeWidget_itemClicked() " << endl;
}
void MainWindow::on_treeWidget_itemCollapsed(QTreeWidgetItem *item)
{
qDebug() << " on_treeWidget_itemCollapsed() " << endl;
}
void MainWindow::on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
{
qDebug() << " on_treeWidget_itemDoubleClicked() " << endl;
}
void MainWindow::on_treeWidget_itemExpanded(QTreeWidgetItem *item)
{
qDebug() << " on_treeWidget_itemExpanded() " << endl;
}
void MainWindow::on_treeWidget_itemPressed(QTreeWidgetItem *item, int column)
{
qDebug() << " on_treeWidget_itemPressed() " << endl;
}
void MainWindow::on_treeWidget_itemSelectionChanged()
{
qDebug() << " on_treeWidget_itemSelectionChanged() " << endl;
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QToolBar>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::ViewInit()
{
QToolBar *toolBar = new QToolBar(this);
addAction(toolBar->toggleViewAction()); // 添加工具栏
QAction *action01 = new QAction(toolBar);
toolBar->addAction(action01);
}
void MainWindow::on_treeWidget_customContextMenuRequested(const QPoint &pos)
{
}
void MainWindow::on_treeWidget_itemEntered(QTreeWidgetItem *item, int column)
{
qDebug() << " on_treeWidget_itemEntered() " << endl;
qDebug() << column << endl;
QString label = item->text(column); // 获取当前的项目标签
int row = ui->treeWidget->indexOfTopLevelItem(item); // 获取项目的行号
qDebug() << "Mouse entered on item:" << label << "in row:" << row << "out of:" << ui->treeWidget->topLevelItemCount() << "rows";
}
void MainWindow::on_treeWidget_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
{
qDebug() << " on_treeWidget_currentItemChanged() " << endl;
}
void MainWindow::on_treeWidget_itemActivated(QTreeWidgetItem *item, int column)
{
qDebug() << " on_treeWidget_itemActivated() " << endl;
}
void MainWindow::on_treeWidget_itemChanged(QTreeWidgetItem *item, int column)
{
qDebug() << " on_treeWidget_itemChanged() " << endl;
}
void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, int column)
{
qDebug() << " on_treeWidget_itemClicked() " << endl;
}
void MainWindow::on_treeWidget_itemCollapsed(QTreeWidgetItem *item)
{
qDebug() << " on_treeWidget_itemCollapsed() " << endl;
}
void MainWindow::on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
{
qDebug() << " on_treeWidget_itemDoubleClicked() " << endl;
}
void MainWindow::on_treeWidget_itemExpanded(QTreeWidgetItem *item)
{
qDebug() << " on_treeWidget_itemExpanded() " << endl;
}
void MainWindow::on_treeWidget_itemPressed(QTreeWidgetItem *item, int column)
{
qDebug() << " on_treeWidget_itemPressed() " << endl;
}
void MainWindow::on_treeWidget_itemSelectionChanged()
{
qDebug() << " on_treeWidget_itemSelectionChanged() " << endl;
}