My Graduation’s project:StudentClassMaintain module

一步步学Qt,第八天-使用QPrinter打印多页文档 一步步学Qt,第八天-使用QPrinter打印多页文档 使用文档打印,在很多的地方都有应用,办公室里可能需要用此来将编辑好的文档打印出来。当然遇到多页文档的打印时,就程序设计来说,就设计到分页的问题,怎么样的分页才是合理的呢。Qt中使用QTextDocument的的方式可以自动 阅读详情
#include "studentclassinfomaintain.h"
#include "ui_studentclassinfomaintain.h"
#include "serverstyle.h"


StudentClassInfoMaintain::StudentClassInfoMaintain(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::StudentClassInfoMaintain)
{
    ui->setupUi(this);
    init();
    createActions();
}

StudentClassInfoMaintain::~StudentClassInfoMaintain()
{
    delete ui;
    studentItemList.clear();
    classItemList.clear();
}

void StudentClassInfoMaintain::setClassMaintainItem(TeachingRoomClass *trClass)
{
    QString trClassName = trClass->getClassName();//get class Name
    QString trClassStudentsCount = trClass->getClassStudentsCount();
    QTreeWidgetItem *currentClass = new QTreeWidgetItem(ui->classList,CLASS_ITEM);
    //set text
    QString classInfo = trClassName +"   "+trClassStudentsCount+CLASSCOUNTUNIT;
    currentClass->setText(0,classInfo);
    classItemList.insert(classInfo,trClass);
}
//set root item
QTreeWidgetItem* StudentClassInfoMaintain::setStudentRootItem(TeachingRoomClass *trClass)
{
    QString trClassName = trClass->getClassName();//get class Name
    QTreeWidgetItem *currentClass = new QTreeWidgetItem(ui->studentsList,CLASS_ITEM);
    //set text
    currentClass->setText(0,trClassName);
    currentClass->setExpanded(true);
    return currentClass;
}
//set root's child
void StudentClassInfoMaintain::setStudentMaintainItem(QTreeWidgetItem *root,TeachingRoomStudents *trStudent)
{
    QString trStudentName = trStudent->getStudentName();//get student Name
    QTreeWidgetItem *currentStudent = new QTreeWidgetItem(root,STUDENT_ITEM);
    //set text
    currentStudent->setText(0,trStudentName);
    //add student to studentitemlist
    studentItemList.insert(trStudentName,trStudent);
}

//conn the signal and slot
void StudentClassInfoMaintain::createActions()
{
    //change the maintain theme
    connect(ui->chooseMaintain,SIGNAL(currentChanged(int)),
            this,SLOT(setCurrentIndex(int)));
    // reget the data from database
    connect(ui->refreshBtn,SIGNAL(clicked()),
            this,SIGNAL(refreshData()));
    //set current class in class maintain
    connect(ui->classList,SIGNAL(itemClicked(QTreeWidgetItem*,int)),
            this,SLOT(setCurrentClassInClassMaintain(QTreeWidgetItem*,int)));
    //set current class in student maintain
    connect(ui->studentsList,SIGNAL(itemClicked(QTreeWidgetItem*,int)),
            this,SLOT(setCurrentClassInStudentMaintain(QTreeWidgetItem*,int)));
    //edit class
    connect(ui->editBtn,SIGNAL(clicked()),
            this,SLOT(editClassInfoSlot()));
    //add new class
    connect(ui->newBtn,SIGNAL(clicked()),
            this,SLOT(addClassInfoSlot()));

}
//clear the list
void StudentClassInfoMaintain::clearList()
{
    ui->classList->clear();
    ui->studentsList->clear();
    studentItemList.clear();
    classItemList.clear();
    ui->className->clear();
}

//init data
void StudentClassInfoMaintain::init()
{
    //unused
    currentIndex = 0;
    tempIndex = 0;
    studentItemList.clear();
    classItemList.clear();
    //set style
    ServerStyle *style = new ServerStyle();
    style->styleNoWork(this);
    //set column width
    setColumnWidth();
}

void StudentClassInfoMaintain::setColumnWidth()
{
    ui->studentInfoWidget->setColumnWidth(TABLEWIDGETITEMROW,TABLEWIDGETITEMWIDTH);
}

//set student list rows
void StudentClassInfoMaintain::setStudentRows(int rows)
{
    ui->studentInfoWidget->setRowCount(rows);
}
//add student to the student table widget
void StudentClassInfoMaintain::addStudentItem(int row, TeachingRoomStudents *student)
{
    QTableWidgetItem *studentIDItem = new QTableWidgetItem(student->getStudentID());
    studentIDItem->setTextAlignment(Qt::AlignHCenter|Qt::AlignBottom);//hcenter and buttom
    ui->studentInfoWidget->setItem(row,0,studentIDItem);
    QTableWidgetItem *studentNameItem = new QTableWidgetItem(student->getStudentName());
    studentNameItem->setTextAlignment(Qt::AlignHCenter|Qt::AlignBottom);//hcenter and buttom
    ui->studentInfoWidget->setItem(row,1,studentNameItem);
    QTableWidgetItem *studentClassItem = new QTableWidgetItem(student->getClassMajor());
    studentClassItem->setTextAlignment(Qt::AlignHCenter|Qt::AlignBottom);//hcenter and buttom
    ui->studentInfoWidget->setItem(row,2,studentClassItem);
    QTableWidgetItem *studentClassCountItem = new QTableWidgetItem(student->getClassCount());
    studentClassCountItem->setTextAlignment(Qt::AlignHCenter|Qt::AlignBottom);//hcenter and buttom
    ui->studentInfoWidget->setItem(row,3,studentClassCountItem);
    QTableWidgetItem *studentGradeItem = new QTableWidgetItem(student->getStudentScore());
    studentGradeItem->setTextAlignment(Qt::AlignHCenter|Qt::AlignBottom);//hcenter and buttom
    ui->studentInfoWidget->setItem(row,4,studentGradeItem);
}
//init class item
void StudentClassInfoMaintain::initClassItemList()
{
    QList<TeachingRoomClass*> classList = classItemList.values();
    int classCount = classList.size();
    for(int index=0; index<classCount; index++){
        QString className = classList.at(index)->getClassName();
        ui->className_2->addItem(className);
    }
}

//change the toolbox index
void StudentClassInfoMaintain::setCurrentIndex(int index)
{
    if(tempIndex==1 && currentIndex==0){
        currentIndex=1;
        tempIndex=0;
    }
    if(index==1 && currentIndex==0){
        currentIndex = 0;
    }
    if(index==1 && currentIndex==1){
        currentIndex = 1;
    }
    if(index==0 && currentIndex==0){
        currentIndex=0;
    }
    if(index==0 && currentIndex==1){
        tempIndex = 1;
        currentIndex=0;
    }
    ui->stackedWidget->setCurrentIndex(index+currentIndex);
}
//set current class
void StudentClassInfoMaintain::setCurrentClassInClassMaintain(QTreeWidgetItem *item,int column)
{
    ui->className->setReadOnly(true);
    ui->studentCount->setReadOnly(true);
    ui->submitBtn->setEnabled(false);
    TeachingRoomClass *currentClass = classItemList.value(item->text(column));
    ui->className->setText(currentClass->getClassName());
    ui->studentCount->setValue(currentClass->getClassStudentsCount().toInt());
}

void StudentClassInfoMaintain::setCurrentClassInStudentMaintain(QTreeWidgetItem *item, int column)
{
    if(item->type() == CLASS_ITEM){//current click item txt :class name
        ui->stackedWidget->setCurrentIndex(1);
        currentIndex = 0;
        emit clickRootItem(item->text(column));
    }
    else{//show maintain student
        ui->stackedWidget->setCurrentIndex(2);
        currentIndex = 1;
        //set current item edit icon
        item->setIcon(0,QIcon(":/server/theme/edit"));
        studentMaintain(item->text(column));
    }
}

//edit current class info
void StudentClassInfoMaintain::editClassInfoSlot()
{
    ui->className->setReadOnly(false);
    ui->studentCount->setReadOnly(false);
    ui->submitBtn->setEnabled(true);
}

//add new class info
void StudentClassInfoMaintain::addClassInfoSlot()
{
    //setting title
    ui->title->setText(ADDCLASSINFOTITLE);
    //setting class name
    ui->className->setText(NEWCLASSNAME);
    ui->className->setFocus();
    ui->className->setReadOnly(false);
    //setting class count
    ui->studentCount->setValue(NEWCLASSCOUNT);
    ui->studentCount->setReadOnly(false);
    ui->submitBtn->setEnabled(true);
}


void StudentClassInfoMaintain::studentMaintain(QString currentStudent)
{
    ui->studentName->setText(currentStudent);
    TeachingRoomStudents *currentstudent = studentItemList.value(currentStudent);
    ui->studentID->setText(currentstudent->getStudentID());
    QString className = currentstudent->getClassMajor();
    ui->className_2->setCurrentIndex(ui->className_2->findText(className));
    ui->classCount->setValue(currentstudent->getClassCount().toInt());
    ui->studentGrade->setValue(currentstudent->getStudentScore().toInt());
}

Qt学习笔记,再次分析EVA源码之后得出的结论-QListView,QListViewItem(Qt3);Q3ListView,Q3ListViewItem(Qt4) Qt学习笔记,再次分析EVA源码之后得出的结论-QListView,QListViewItem(Qt3);Q3ListView,Q3ListViewItem(Qt4) 今天再次分析了Eva的源码,也看了qt3中QListView和QListViewItem手册,在Eva 阅读详情

相关推荐

一步步学Qt,第七天-QPainter绘图QRect定位问题

一步步学Qt,第七天-QPainter绘图QRect定位问题 昨天工作室没电,现在才能继续Qt。 一直对Qpainter的绘图功能不断研究中,很多的不明白,因为他的工作往往就是几个class的综合,看一个demo,在对整个demo的结构不是很明白的前提下,这个是很头疼

Qicz的学习笔记 博客新址:izcqi.com 3368

Qt学习笔记,设置QTabWidget的TabBar的属性

Qt学习笔记,设置QTabWidget的TabBar的属性 ui->tabWidget->setStyleSheet("QTabBar::tab { height: 25px; width:25px;color: white; padding: 0px;

Qicz的学习笔记 博客新址:izcqi.com 8116

一步步学Qt.第二天-续集-mysql连接成功

不断辛苦,不断尝试,这把才将mysql的驱动ok了. 写了一个小小的demo #include #include #include #include #include int main(int argc,char *argv[]){ QApplica

Qicz的学习笔记 博客新址:izcqi.com 2853

Qt学习笔记,修改指定图片的大小,转换为QIcon用于QPushButton等控件

Qt学习笔记,修改指定图片的大小,转换为QIcon用于QPushButton等控件 QString imagepath = ":/images/btn.png"; QPixmap image0(imagepath); QPixmap image =

Qicz的学习笔记 博客新址:izcqi.com 7630

Qt学习笔记,使用QDir获取当前目录下所有目录和文件信息

Qt学习笔记,使用QDir获取当前目录下所有目录和文件信息 #include #include #include int main(int argc,char *argv[]){ QApplication app(argc,argv);

Qicz的学习笔记 博客新址:izcqi.com 7269

Qt学习笔记,QWidget和QMainWindow新认识

Qt学习笔记,QWidget和QMainWindow新认识 学习Qt这么久了,今天才发现,原来QWidget不是我想象的那种东西。居然给她设置背景是那么的不方便的。在这里得到的方式如下: //在Qt3中,使用QWidget::setBackgroundPixm

Qicz的学习笔记 博客新址:izcqi.com 5740

一步步学Qt,第五天-Qt这样的小小差异你发现了多少

一步步学Qt,第5天-Qt这样的小小差异你发现了多少 今天下了一个小小得程序,一个小小的文件目录浏览器。在看到这个地方的时候,看到了Qt你们的Model/View模式,原本小弟疑问这个玩意没有什么模式,自己借用其他的设计模式应该可以的。没想到Qt自己有自己的一套模式。不

Qicz的学习笔记 博客新址:izcqi.com 2897

Qt学习笔记,Qt程序架构设计要旨

Qt学习笔记,Qt程序架构设计要旨 时间过得很快,转眼学习Qt已经有一个多月了,对Qt的学习也在不断的深入中。自己手下的code也很多了,不过不得不说,还有很多的部分没有接触过,比如网络编程,2D,3D等等,但这些会在接下来的工作里不断的接触和深入。现在学习Qt的心得就

Qicz的学习笔记 博客新址:izcqi.com 2819

一步步学Qt,第九天-Q”STL”与STL-再看C++

一步步学Qt,第九天-Q”STL”与STL-再看C++ 第一次在一步步学Qt中看到了C++的图了,或许自己也都忘记了Qt是基于C++的一个拓展的框架。不过Qt与C++的关系是莫大的,Qt她的很多的思想都引用于C++,在 一步步学Qt,第五天-Qt学习小结-Qt工作机制 也有

Qicz的学习笔记 博客新址:izcqi.com 1742

一步步学Qt,第九天-Q"STL"与STL-Qvector,vector

一步步学Qt,第九天-Q"STL"与STL-Qvector,vector 这个部分或许没有代码出现,更多的是文字分析,即使会出现也可能就是很简短的部分。今天主要来分析和对比一下Q”STL”与C++的STL,主要讲解他们各自在定义和使用的区别,不仅仅是学习C++的提升也是对Q

Qicz的学习笔记 博客新址:izcqi.com 1733

一步步学Qt,第四天-Qt 建立MainWindow遇到的问题,也是常见GUI工具的问题

一步步学Qt,第四天-Qt 建立MainWindow遇到的问题,也是常见GUI工具的问题 今天写了一个MainWidow,但是遇到的问题,很有意思,先看效果吧:(期望的效果) 结果我的结果是: 也就是,资源文件没有加载. 就在此刻,我突然的冒出来,

Qicz的学习笔记 博客新址:izcqi.com 1696

一步步学Qt,第一天

今天是Qt的第一天,越到了很多的问题,不过还好都已经解决了。下面记录一下: qt incomplete type 这个问题,我刚遇到的时候,以后是自己疏忽没有写好code,后来去参考demo程序,发现自己没有错误。不错那个提示却一再的出现。于是,google,

Qicz的学习笔记 博客新址:izcqi.com 1655

Qt 无边框窗口自己实现拖拽与缩放

flyfish

二分掌柜的 375

Qt 面试(一)

源文件 (.cpp/.c):内部实现,不对外分发。头文件 (.h/.hpp):对外接口,放类声明、函数声明、宏。更新库不用重编译程序;调用者只包含头文件,链接库文件,看不到内部 cpp 源码。

qq_59167692的博客 134

QT程序界面自适应1080/2K/4K屏幕。qputenv或者setAttribute

QT程序界面自适应1080/2K/4K屏幕。qputenv或者setAttribute

sunflower_2020的博客 91

anaconda python环境和QT python环境不一致如何解决

问的deepseek,我的问题是anaconda和qt环境python不一样,导致QT每次新建项目都必须重新下载pyside6

狮子雨恋 291

Qt5Widgets.dll 加载失败排查:Qt 插件路径、程序位数与部署目录如何对应

Qt5Widgets.dll 加载失败常见于 Qt 桌面程序部署不完整、Debug 与 Release 文件混用,或者 32 位和 64 位库没有对应。技术排查不应只看同名文件是否存在,还要确认主程序架构、Qt 小版本、插件目录和实际搜索路径。 ## 一、Qt5Widgets.dll 报错时用事件日志定位实际加载路径 在事件查看器应用日志中记录故障应用、模块

2301_78581598的博客 219
上一篇:
下一篇: taskmgr
Qicz
博客等级 码龄15年 56粉丝 122原创
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值