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

📄 interface.cpp

📁 很好的 QT 学习源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
#include<qapplication.h>
#include<qwidget.h>
#include<qpushbutton.h>
#include<qfont.h>
#include<qlabel.h>
#include<qtable.h>
#include"interface.h"
#include"land_face.h"

class Major;
class Order;
class Search;
//*************************主界面的界面实现****************************
Major::Major()
{        
		setCaption("interface"); 
        setGeometry(0,0,240,320);
        setPaletteBackgroundColor( QColor( 233, 239, 190 ) );

        textLabel1 = new QLabel("Interface",this);
        textLabel1->setGeometry(0,0,240,30);
        textLabel1->setFont(QFont("Times",9));

        pushButton1 = new QPushButton("Order",this);
        pushButton1->setGeometry(25,60,80,30);
        pushButton1->setFont(QFont("Times",9));
        

        pushButton2 = new QPushButton("Search",this);
        pushButton2->setGeometry(135,60,80,30);
        pushButton2->setFont(QFont("Times",9));

        pushButton3 = new QPushButton("Land",this); 
        pushButton3->setGeometry(25,110,80,30);
        pushButton3->setFont(QFont("Times",9));

        pushButton4 = new QPushButton("Quit",this); 
        pushButton4->setGeometry(135,110,80,30);
        pushButton4->setFont(QFont("Times",9));

	    connect(pushButton4,SIGNAL(clicked()),qApp,SLOT(quit()));

 	    textLabel2 = new QLabel("LAN Electronics la carte System",this);
	    textLabel2->setGeometry(0,200,240,40);
	    textLabel2->setFont(QFont("Times",9)); 
	    
	    show();
	    
	    /*主界面中的点菜按钮order和oder界面的实现建立信号和槽机制*/
	    connect(pushButton1,SIGNAL(clicked()),SLOT(sendto_order()));
	    connect(pushButton1,SIGNAL(clicked()),this,SLOT(close()));
	    
	    /*主界面中的查台按钮serach和search界面的实现建立连接*/
	//    Search *search=new Search;
	    connect(pushButton2,SIGNAL(clicked()),SLOT(sendto_search()));
	    connect(pushButton2,SIGNAL(clicked()),this,SLOT(close()));
	    connect(pushButton3,SIGNAL(clicked()),SLOT(send_signals()));	    	    
  }
 
//============================order界面函数的实现================================
/*
 *  Constructs a Form2 as a child of 'parent', with the
 *  name 'name' and widget flags set to 'f'.
 */
Order::Order()
{
    setGeometry(0,0,240,320);
    setCaption("Order");
    setPaletteBackgroundColor( QColor( 233, 239, 190 ) );

    textLabel1 = new QLabel( this, "textLabel1" );
    textLabel1->setGeometry( QRect( 20, 0, 60, 20 ) );
    comboBox0 = new QComboBox( this, "comboBox1" );
    comboBox0->setGeometry( QRect( 80, 0, 150, 20 ) );

    edit1 = new QLineEdit( this, "edit" );
    edit1->setGeometry( QRect( 5, 25, 125, 20 ) );    
    comboBox1 = new QComboBox( this, "comboBox2" );
    comboBox1->setGeometry( QRect( 130, 25, 65, 20 ) );
    spinBox1 = new QSpinBox( this, "spinBox1" );
    spinBox1->setGeometry( QRect( 195, 25, 40, 20 ) );
    spinBox1->setFont(QFont("Times",9));
    spinBox1->setMaxValue( 99 );

    edit2 = new QLineEdit( this, "edit2" );
    edit2->setGeometry( QRect( 5, 48, 125, 20  ) );  
    comboBox2 = new QComboBox( this, "comboBox3" );
    comboBox2->setGeometry( QRect( 130, 48, 65, 20 ) );
    spinBox2 = new QSpinBox( this, "spinBox2" );
    spinBox2->setGeometry( QRect( 195, 48, 40, 20 ) );
    spinBox2->setFont(QFont("Times",9));
    spinBox2->setMaxValue( 99 );

    edit3 = new QLineEdit( this, "edit3" );
    edit3->setGeometry( QRect( 5, 71, 125, 20 ) );   
    comboBox3 = new QComboBox( this, "comboBox3" );
    comboBox3->setGeometry( QRect( 130, 71, 65, 20) );
    spinBox3 = new QSpinBox( this, "spinBox3" );
    spinBox3->setGeometry( QRect( 195, 71, 40, 20 ) );
    spinBox3->setFont(QFont("Times",9));
    spinBox3->setMaxValue( 99 );

    edit4 = new QLineEdit( this, "edit4" );
    edit4->setGeometry( QRect( 5, 94, 125, 20 ) );   
    comboBox4 = new QComboBox( this, "comboBox4" );
    comboBox4->setGeometry( QRect( 130, 94, 65, 20) );
    spinBox4 = new QSpinBox( this, "spinBox4" );
    spinBox4->setGeometry( QRect( 195, 94, 40, 20 ) );
    spinBox4->setFont(QFont("Times",9));
    spinBox4->setMaxValue( 99 ); 

    edit5 = new QLineEdit( this, "edit5" );
    edit5->setGeometry( QRect( 5, 117, 125, 20 ) );  
    comboBox5 = new QComboBox( this, "comboBox5" );
    comboBox5->setGeometry( QRect( 130, 117, 65, 20) );
    spinBox5 = new QSpinBox( this, "spinBox5" );
    spinBox5->setGeometry( QRect( 195, 117, 40, 20 ) );
    spinBox5->setFont(QFont("Times",9));
    spinBox5->setMaxValue( 99 );

    edit6 = new QLineEdit( this, "edit6" );
    edit6->setGeometry( QRect( 5, 140, 125, 20 ) );   
    comboBox6 = new QComboBox( this, "comboBox6" );
    comboBox6->setGeometry( QRect( 130, 140, 65, 20) );
    spinBox6 = new QSpinBox( this, "spinBox6" );
    spinBox6->setGeometry( QRect( 195, 140, 40, 20 ) );
    spinBox6->setFont(QFont("Times",9));
    spinBox6->setMaxValue( 99 );

    edit7 = new QLineEdit( this, "edit7" );
    edit7->setGeometry( QRect( 5, 163, 125, 20 ) );   
    comboBox7 = new QComboBox( this, "comboBox7" );
    comboBox7->setGeometry( QRect( 130, 163, 65, 20) );
    spinBox7 = new QSpinBox( this, "spinBox7" );
    spinBox7->setGeometry( QRect( 195, 163, 40, 20 ) );
    spinBox7->setFont(QFont("Times",9));
    spinBox7->setMaxValue( 99 );

    edit8 = new QLineEdit( this, "edit8" );
    edit8->setGeometry( QRect( 5, 186, 125, 20 ) );   
    comboBox8 = new QComboBox( this, "comboBox8" );
    comboBox8->setGeometry( QRect( 130, 186, 65, 20) );
    spinBox8 = new QSpinBox( this, "spinBox8" );
    spinBox8->setGeometry( QRect( 195, 186, 40, 20 ) );
    spinBox8->setFont(QFont("Times",9));
    spinBox8->setMaxValue( 99 );

    edit9 = new QLineEdit( this, "edit9" );
    edit9->setGeometry( QRect( 5, 209, 125, 20 ) );   
    comboBox9 = new QComboBox( this, "comboBox9" );
    comboBox9->setGeometry( QRect( 130, 209, 65, 20) );
    spinBox9 = new QSpinBox( this, "spinBox9" );
    spinBox9->setGeometry( QRect( 195, 209, 40, 20 ) );
    spinBox9->setFont(QFont("Times",9));
    spinBox9->setMaxValue( 99 );

    edit10 = new QLineEdit( this, "edit10" );
    edit10->setGeometry( QRect( 5, 232, 125, 20 ) );   
    comboBox10 = new QComboBox( this, "comboBox10" );
    comboBox10->setGeometry( QRect( 130, 232, 65, 20) );
    spinBox10 = new QSpinBox( this, "spinBox10" );
    spinBox10->setGeometry( QRect( 195, 232, 40, 20 ) );
    spinBox10->setFont(QFont("Times",9));
    spinBox10->setMaxValue( 99 );

    pushButton1 = new QPushButton("up",this, "pushButton1" );
    pushButton1->setGeometry( QRect( 8, 255, 50, 25 ) );
    pushButton1->setFont(QFont("Times",9)); 

    pushButton2 = new QPushButton("down",this, "pushButton2" );
    pushButton2->setGeometry( QRect( 66, 255, 50, 25 ) );
    pushButton2->setFont(QFont("Times",9)); 

    pushButton3 = new QPushButton("ok",this, "pushButton3" );
    pushButton3->setGeometry( QRect( 124, 255, 50, 25 ) );
    pushButton3->setFont(QFont("Times",9)); 

    pushButton4 = new QPushButton("back",this, "pushButton4" );
    pushButton4->setGeometry( QRect( 182, 255, 50, 25 ) );
    pushButton4->setFont(QFont("Times",9)); 

    languageChange();

     
       //用ok实现确定后的菜单
 
    connect(pushButton3,SIGNAL(clicked()),SLOT(sendto_order2()));
    connect(pushButton3,SIGNAL(clicked()),this,SLOT(close()));
    
       //用pushButton4实现界面的返回,back回到order界面

    connect(pushButton4,SIGNAL(clicked()),SLOT(sendto_major()));
    connect(pushButton4,SIGNAL(clicked()),this,SLOT(close()));  
    
    
}


/*
 *  Sets the strings of the subwidgets using the current
 *  language.
 */
void Order::languageChange()
{

    textLabel1->setText( trUtf8( "Sort" ) );
    textLabel1->setFont(QFont("Times",9));  
    comboBox0->clear();
    comboBox0->setFont(QFont("Times",9));
    comboBox0->insertItem( tr( "0" ) );
    comboBox0->insertItem( tr( "1" ) );
    comboBox0->insertItem( tr( "2" ) );
    comboBox0->insertItem( tr( "3" ) );

    comboBox1->clear();
    comboBox1->insertItem( trUtf8( "taste" ) );
    comboBox1->setFont(QFont("Times",8));
    comboBox1->insertItem( tr( "1" ) );
    comboBox1->insertItem( tr( "2" ) );
    comboBox1->insertItem( tr( "3" ) );
    
    comboBox2->clear();
    comboBox2->insertItem( trUtf8( "taste" ) );
    comboBox2->setFont(QFont("Times",8));
    comboBox2->insertItem( tr( "1" ) );
    comboBox2->insertItem( tr( "2" ) );
    comboBox2->insertItem( tr( "3" ) );

    comboBox3->clear();
    comboBox3->insertItem( trUtf8( "taste" ) );
    comboBox3->setFont(QFont("Times",8));
    comboBox3->insertItem( tr( "1" ) );
    comboBox3->insertItem( tr( "2" ) );
    comboBox3->insertItem( tr( "3" ) );

    comboBox4->clear();
    comboBox4->insertItem( trUtf8( "taste" ) );
    comboBox4->setFont(QFont("Times",8));
    comboBox4->insertItem( tr( "1" ) );
    comboBox4->insertItem( tr( "2" ) );
    comboBox4->insertItem( tr( "3" ) );

    comboBox5->clear();
    comboBox5->insertItem( trUtf8( "taste" ) );
    comboBox5->setFont(QFont("Times",8));
    comboBox5->insertItem( tr( "1" ) );
    comboBox5->insertItem( tr( "2" ) );
    comboBox5->insertItem( tr( "3" ) );

    comboBox6->clear();
    comboBox6->insertItem( trUtf8( "taste" ) );
    comboBox6->setFont(QFont("Times",8));
    comboBox6->insertItem( tr( "1" ) );
    comboBox6->insertItem( tr( "2" ) );
    comboBox6->insertItem( tr( "3" ) );

    comboBox7->clear();
    comboBox7->insertItem( trUtf8( "taste" ) );
    comboBox7->setFont(QFont("Times",8));
    comboBox7->insertItem( tr( "1" ) );
    comboBox7->insertItem( tr( "2" ) );
    comboBox7->insertItem( tr( "3" ) );

    comboBox8->clear();
    comboBox8->insertItem( trUtf8( "taste" ) );
    comboBox8->setFont(QFont("Times",8));
    comboBox8->insertItem( tr( "1" ) );
    comboBox8->insertItem( tr( "2" ) );
    comboBox8->insertItem( tr( "3" ) );

    comboBox9->clear();
    comboBox9->insertItem( trUtf8( "taste" ) );
    comboBox9->setFont(QFont("Times",8));
    comboBox9->insertItem( tr( "1" ) );
    comboBox9->insertItem( tr( "2" ) );
    comboBox9->insertItem( tr( "3" ) );

    comboBox10->clear();
    comboBox10->insertItem( trUtf8( "taste" ) );
    comboBox10->setFont(QFont("Times",8));
    comboBox10->insertItem( tr( "1" ) );
    comboBox10->insertItem( tr( "2" ) );
    comboBox10->insertItem( tr( "3" ) );
}

//----------------------order界面中按下ok后产生的menu界面的实现-------------------------------
/*
 *  Constructs a Form1 as a child of 'parent', with the
 *  name 'name' and widget flags set to 'f'.
 */
Order2::Order2()
{
    setGeometry(0,0,240,320);
    setCaption("Order");
    setPaletteBackgroundColor( QColor( 233, 239, 190 ) );

    setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, 0, 0, sizePolicy().hasHeightForWidth() ) );

    table1 = new QTable( this, "table1" );
    table1->setFont(QFont("Times",9));
    table1->setNumCols( table1->numCols() + 1 );
    table1->horizontalHeader()->setLabel( table1->numCols() - 1, trUtf8( "dish" ) );
    table1->setNumCols( table1->numCols() + 1 );
    table1->horizontalHeader()->setLabel( table1->numCols() - 1, trUtf8( "price" ) );
    table1->setNumCols( table1->numCols() + 1 );
    table1->horizontalHeader()->setLabel( table1->numCols() - 1, trUtf8( "number" ) );
    table1->setNumCols( table1->numCols() + 1 );
    table1->horizontalHeader()->setLabel( table1->numCols() - 1, trUtf8( "sum" ) );
    table1->setNumCols( table1->numCols() + 1 );
    table1->horizontalHeader()->setLabel( table1->numCols() - 1, trUtf8( "modify" ) );
    table1->setNumRows( table1->numRows() + 1 );
    table1->verticalHeader()->setLabel( table1->numRows() - 1, tr( "1" ) );
    table1->setNumRows( table1->numRows() + 1 );
    table1->verticalHeader()->setLabel( table1->numRows() - 1, tr( "2" ) );
    table1->setNumRows( table1->numRows() + 1 );
    table1->verticalHeader()->setLabel( table1->numRows() - 1, tr( "3" ) );
    table1->setNumRows( table1->numRows() + 1 );
    table1->verticalHeader()->setLabel( table1->numRows() - 1, tr( "4" ) );
    table1->setNumRows( table1->numRows() + 1 );
    table1->verticalHeader()->setLabel( table1->numRows() - 1, tr( "5" ) );
    table1->setNumRows( table1->numRows() + 1 );
    table1->verticalHeader()->setLabel( table1->numRows() - 1, tr( "6" ) );

⌨️ 快捷键说明

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