⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainform.cpp

📁 学生管理系统 使用Qt写的界面 交互性好
💻 CPP
字号:
/****************************************************************************** Form implementation generated from reading ui file 'mainform.ui'**** Created: 星期三 六月 27 10:09:42 2007**      by: The User Interface Compiler ()**** WARNING! All changes made in this file will be lost!****************************************************************************/#include "mainform.h"#include <qvariant.h>#include <qtabwidget.h>#include <qwidget.h>#include <qpushbutton.h>#include <qheader.h>#include <qlistview.h>#include <qlayout.h>#include <qtooltip.h>#include <qwhatsthis.h>#include <qaction.h>#include <qmenubar.h>#include <qpopupmenu.h>#include <qtoolbar.h>#include <qimage.h>#include <qpixmap.h>#include "mainform.ui.h"/* *  Constructs a Form1 as a child of 'parent', with the *  name 'name' and widget flags set to 'f'. * */Form1::Form1( QWidget* parent, const char* name, WFlags fl )    : QMainWindow( parent, name, fl ){    (void)statusBar();    if ( !name )	setName( "Form1" );    setIcon( QPixmap::fromMimeSource( "mainicon.png" ) );    setCentralWidget( new QWidget( this, "qt_central_widget" ) );    tabWidget1 = new QTabWidget( centralWidget(), "tabWidget1" );    tabWidget1->setGeometry( QRect( 0, 0, 590, 460 ) );    student = new QWidget( tabWidget1, "student" );    pushButton2 = new QPushButton( student, "pushButton2" );    pushButton2->setGeometry( QRect( 370, 400, 83, 25 ) );    pushButton3 = new QPushButton( student, "pushButton3" );    pushButton3->setGeometry( QRect( 460, 400, 83, 25 ) );    pushButton1 = new QPushButton( student, "pushButton1" );    pushButton1->setGeometry( QRect( 180, 400, 83, 25 ) );    pushButton79 = new QPushButton( student, "pushButton79" );    pushButton79->setGeometry( QRect( 270, 400, 90, 25 ) );    pushButton72 = new QPushButton( student, "pushButton72" );    pushButton72->setGeometry( QRect( 80, 400, 90, 25 ) );    listView1 = new QListView( student, "listView1" );    listView1->addColumn( tr( "            ID            " ) );    listView1->addColumn( tr( "            Name            " ) );    listView1->addColumn( tr( "    Age    " ) );    listView1->addColumn( tr( "    Sex    " ) );    listView1->setGeometry( QRect( 10, 10, 560, 380 ) );    tabWidget1->insertTab( student, QString::fromLatin1("") );    course = new QWidget( tabWidget1, "course" );    pushButton72_2 = new QPushButton( course, "pushButton72_2" );    pushButton72_2->setGeometry( QRect( 80, 400, 90, 25 ) );    pushButton2_2 = new QPushButton( course, "pushButton2_2" );    pushButton2_2->setGeometry( QRect( 370, 400, 83, 25 ) );    pushButton1_2 = new QPushButton( course, "pushButton1_2" );    pushButton1_2->setGeometry( QRect( 180, 400, 83, 25 ) );    pushButton79_2 = new QPushButton( course, "pushButton79_2" );    pushButton79_2->setGeometry( QRect( 270, 400, 90, 25 ) );    pushButton3_2 = new QPushButton( course, "pushButton3_2" );    pushButton3_2->setGeometry( QRect( 460, 400, 83, 25 ) );    listView2 = new QListView( course, "listView2" );    listView2->addColumn( tr( "        ID        " ) );    listView2->addColumn( tr( "             Name            " ) );    listView2->addColumn( tr( "Point" ) );    listView2->addColumn( tr( "Teacher Name" ) );    listView2->addColumn( tr( "TeacherID" ) );    listView2->setGeometry( QRect( 10, 10, 560, 380 ) );    tabWidget1->insertTab( course, QString::fromLatin1("") );    score = new QWidget( tabWidget1, "score" );    pushButton165 = new QPushButton( score, "pushButton165" );    pushButton165->setGeometry( QRect( 170, 400, 97, 25 ) );    pushButton1_4 = new QPushButton( score, "pushButton1_4" );    pushButton1_4->setGeometry( QRect( 280, 400, 83, 25 ) );    pushButton2_4 = new QPushButton( score, "pushButton2_4" );    pushButton2_4->setGeometry( QRect( 490, 400, 83, 25 ) );    pushButton166 = new QPushButton( score, "pushButton166" );    pushButton166->setGeometry( QRect( 380, 400, 97, 25 ) );    listView3 = new QListView( score, "listView3" );    listView3->addColumn( tr( "        StudentID        " ) );    listView3->addColumn( tr( "        CourseID        " ) );    listView3->addColumn( tr( "grade" ) );    listView3->setGeometry( QRect( 10, 10, 560, 380 ) );    tabWidget1->insertTab( score, QString::fromLatin1("") );    Stat1 = new QWidget( tabWidget1, "Stat1" );    listView4 = new QListView( Stat1, "listView4" );    listView4->addColumn( tr( "        StudentID        " ) );    listView4->addColumn( tr( "            StudentName            " ) );    listView4->addColumn( tr( "Average" ) );    listView4->setGeometry( QRect( 10, 10, 560, 380 ) );    pushButton179 = new QPushButton( Stat1, "pushButton179" );    pushButton179->setGeometry( QRect( 450, 400, 97, 25 ) );    tabWidget1->insertTab( Stat1, QString::fromLatin1("") );    Stat2 = new QWidget( tabWidget1, "Stat2" );    pushButton180 = new QPushButton( Stat2, "pushButton180" );    pushButton180->setGeometry( QRect( 460, 400, 97, 25 ) );    listView5 = new QListView( Stat2, "listView5" );    listView5->addColumn( tr( "        CourseID        " ) );    listView5->addColumn( tr( "       CourseName        " ) );    listView5->addColumn( tr( "Average" ) );    listView5->addColumn( tr( "percent of pass(%)" ) );    listView5->setGeometry( QRect( 10, 10, 560, 380 ) );    tabWidget1->insertTab( Stat2, QString::fromLatin1("") );    // actions    fileNewAction = new QAction( this, "fileNewAction" );    fileNewAction->setIconSet( QIconSet( QPixmap::fromMimeSource( "" ) ) );    fileOpenAction = new QAction( this, "fileOpenAction" );    fileOpenAction->setIconSet( QIconSet( QPixmap::fromMimeSource( "" ) ) );    fileSaveAction = new QAction( this, "fileSaveAction" );    fileSaveAction->setIconSet( QIconSet( QPixmap::fromMimeSource( "" ) ) );    fileSaveAsAction = new QAction( this, "fileSaveAsAction" );    filePrintAction = new QAction( this, "filePrintAction" );    filePrintAction->setIconSet( QIconSet( QPixmap::fromMimeSource( "" ) ) );    fileExitAction = new QAction( this, "fileExitAction" );    helpContentsAction = new QAction( this, "helpContentsAction" );    helpIndexAction = new QAction( this, "helpIndexAction" );    helpAboutAction = new QAction( this, "helpAboutAction" );    // toolbars    // menubar    MenuBar = new QMenuBar( this, "MenuBar" );    fileMenu = new QPopupMenu( this );    fileNewAction->addTo( fileMenu );    fileOpenAction->addTo( fileMenu );    fileSaveAction->addTo( fileMenu );    fileMenu->insertSeparator();    fileExitAction->addTo( fileMenu );    MenuBar->insertItem( QString(""), fileMenu, 1 );    helpMenu = new QPopupMenu( this );    helpContentsAction->addTo( helpMenu );    helpIndexAction->addTo( helpMenu );    helpMenu->insertSeparator();    helpAboutAction->addTo( helpMenu );    MenuBar->insertItem( QString(""), helpMenu, 2 );    languageChange();    resize( QSize(600, 515).expandedTo(minimumSizeHint()) );    clearWState( WState_Polished );    // signals and slots connections    connect( helpAboutAction, SIGNAL( activated() ), this, SLOT( helpAbout() ) );    connect( helpContentsAction, SIGNAL( activated() ), this, SLOT( helpContents() ) );    connect( helpIndexAction, SIGNAL( activated() ), this, SLOT( helpIndex() ) );    connect( fileExitAction, SIGNAL( activated() ), this, SLOT( close() ) );    connect( filePrintAction, SIGNAL( activated() ), this, SLOT( filePrint() ) );    connect( fileSaveAsAction, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );    connect( fileSaveAction, SIGNAL( activated() ), this, SLOT( fileSave() ) );    connect( fileOpenAction, SIGNAL( activated() ), this, SLOT( fileOpen() ) );    connect( fileNewAction, SIGNAL( activated() ), this, SLOT( fileNew() ) );    connect( pushButton1, SIGNAL( clicked() ), this, SLOT( Add() ) );    connect( pushButton2, SIGNAL( clicked() ), this, SLOT( Confirm() ) );    connect( pushButton3, SIGNAL( clicked() ), this, SLOT( Search() ) );    connect( pushButton72, SIGNAL( clicked() ), this, SLOT( ShowAllStudent() ) );    connect( pushButton79, SIGNAL( clicked() ), this, SLOT( Modify() ) );    connect( pushButton72_2, SIGNAL( clicked() ), this, SLOT( showAllCourse() ) );    connect( pushButton2_2, SIGNAL( clicked() ), this, SLOT( Confirm() ) );    connect( pushButton1_2, SIGNAL( clicked() ), this, SLOT( AddCourse() ) );    connect( pushButton79_2, SIGNAL( clicked() ), this, SLOT( ModifyCourse() ) );    connect( pushButton3_2, SIGNAL( clicked() ), this, SLOT( Search2() ) );    connect( pushButton2_4, SIGNAL( clicked() ), this, SLOT( Confirm() ) );    connect( pushButton1_4, SIGNAL( clicked() ), this, SLOT( AddScore() ) );    connect( pushButton165, SIGNAL( clicked() ), this, SLOT( ShowAllScore() ) );    connect( tabWidget1, SIGNAL( currentChanged(QWidget*) ), this, SLOT( pageChanged() ) );    connect( pushButton166, SIGNAL( clicked() ), this, SLOT( ModifyScore() ) );    connect( pushButton179, SIGNAL( clicked() ), this, SLOT( StudentStat() ) );    connect( pushButton180, SIGNAL( clicked() ), this, SLOT( CourseStat() ) );    init();}/* *  Destroys the object and frees any allocated resources */Form1::~Form1(){    // no need to delete child widgets, Qt does it all for us}/* *  Sets the strings of the subwidgets using the current *  language. */void Form1::languageChange(){    setCaption( tr( "SMS" ) );    setIconText( tr( "SMS" ) );    QToolTip::add( tabWidget1, tr( "infomation" ) );    pushButton2->setText( tr( "DELETE" ) );    pushButton3->setText( tr( "SEARCH" ) );    pushButton1->setText( tr( "ADD" ) );    pushButton79->setText( tr( "Modify" ) );    pushButton72->setText( tr( "Show All" ) );    listView1->header()->setLabel( 0, tr( "            ID            " ) );    listView1->header()->setLabel( 1, tr( "            Name            " ) );    listView1->header()->setLabel( 2, tr( "    Age    " ) );    listView1->header()->setLabel( 3, tr( "    Sex    " ) );    tabWidget1->changeTab( student, tr( "Student" ) );    pushButton72_2->setText( tr( "Show All" ) );    pushButton2_2->setText( tr( "DELETE" ) );    pushButton1_2->setText( tr( "ADD" ) );    pushButton79_2->setText( tr( "Modify" ) );    pushButton3_2->setText( tr( "SEARCH" ) );    listView2->header()->setLabel( 0, tr( "        ID        " ) );    listView2->header()->setLabel( 1, tr( "             Name            " ) );    listView2->header()->setLabel( 2, tr( "Point" ) );    listView2->header()->setLabel( 3, tr( "Teacher Name" ) );    listView2->header()->setLabel( 4, tr( "TeacherID" ) );    tabWidget1->changeTab( course, tr( "Course" ) );    pushButton165->setText( tr( "Show All" ) );    pushButton1_4->setText( tr( "ADD" ) );    pushButton2_4->setText( tr( "DELETE" ) );    pushButton166->setText( tr( "Modify" ) );    listView3->header()->setLabel( 0, tr( "        StudentID        " ) );    listView3->header()->setLabel( 1, tr( "        CourseID        " ) );    listView3->header()->setLabel( 2, tr( "grade" ) );    tabWidget1->changeTab( score, tr( "Score" ) );    listView4->header()->setLabel( 0, tr( "        StudentID        " ) );    listView4->header()->setLabel( 1, tr( "            StudentName            " ) );    listView4->header()->setLabel( 2, tr( "Average" ) );    pushButton179->setText( tr( "Refresh" ) );    tabWidget1->changeTab( Stat1, tr( "Stat. of student" ) );    pushButton180->setText( tr( "Refresh" ) );    listView5->header()->setLabel( 0, tr( "        CourseID        " ) );    listView5->header()->setLabel( 1, tr( "       CourseName        " ) );    listView5->header()->setLabel( 2, tr( "Average" ) );    listView5->header()->setLabel( 3, tr( "percent of pass(%)" ) );    tabWidget1->changeTab( Stat2, tr( "Stat. of course" ) );    fileNewAction->setText( tr( "New" ) );    fileNewAction->setMenuText( tr( "&New" ) );    fileNewAction->setAccel( tr( "Ctrl+N" ) );    fileOpenAction->setText( tr( "Open" ) );    fileOpenAction->setMenuText( tr( "&Open..." ) );    fileOpenAction->setAccel( tr( "Ctrl+O" ) );    fileSaveAction->setText( tr( "Save" ) );    fileSaveAction->setMenuText( tr( "&Save" ) );    fileSaveAction->setAccel( tr( "Ctrl+S" ) );    fileSaveAsAction->setText( tr( "Save As" ) );    fileSaveAsAction->setMenuText( tr( "Save &As..." ) );    fileSaveAsAction->setAccel( QString::null );    filePrintAction->setText( tr( "Print" ) );    filePrintAction->setMenuText( tr( "&Print..." ) );    filePrintAction->setAccel( tr( "Ctrl+P" ) );    fileExitAction->setText( tr( "Exit" ) );    fileExitAction->setMenuText( tr( "E&xit" ) );    fileExitAction->setAccel( QString::null );    helpContentsAction->setText( tr( "Contents" ) );    helpContentsAction->setMenuText( tr( "&Contents..." ) );    helpContentsAction->setAccel( QString::null );    helpIndexAction->setText( tr( "Index" ) );    helpIndexAction->setMenuText( tr( "&Index..." ) );    helpIndexAction->setAccel( QString::null );    helpAboutAction->setText( tr( "About" ) );    helpAboutAction->setMenuText( tr( "&About" ) );    helpAboutAction->setAccel( QString::null );    if (MenuBar->findItem(1))        MenuBar->findItem(1)->setText( tr( "&File" ) );    if (MenuBar->findItem(2))        MenuBar->findItem(2)->setText( tr( "&Help" ) );}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -