zoukankan      html  css  js  c++  java
  • QT学习2:QFont和退出

     
    #define QT3_SUPPORT
    #include "hello.h"
    #include <QApplication>//在每一个使用QT的应用程序中都必须使用QApplication,它管理了各种
    //应用程序的广泛资源,比如默认字体和光标
    #include <QPushButton.h>//经典的图形用户界面按钮,QWidget,可以显示一段文本或QPixmap
    #include <QFont.h>//QT中的字体
    int main(int argc, char *argv[])
    {
    	QApplication a(argc, argv);//argc是命令行变量的数量,argv是数组,C、C++特征
    
        QPushButton quit("Quit", 0);
    	quit.resize(75, 30);
    	quit.setFont(QFont(("Arial"), 18, QFont::Bold));
    
    	//---QT的信息槽机制 --------------------
    	//---这是个静态函数 --------------------
    	//---connect把quit的clicked信号和a的quit槽连接起来了
    	QObject::connect(&quit, SIGNAL(clicked()), &a, SLOT(quit()));
       
    	//-------------------------------------------
    	//void QApplication::setMainWidget ( QWidget * mainWidget )
    	//设置应用程序的主窗口部件为hello.
    	//它退出,程序也退出了,这个好像只能在QT3_SUPPORT定义后使用
    	//-------------------------------------------
    	a.setMainWidget(&quit);
    
    	//--------------------------------------------
    	// Shows the widget and its child widgets. 
    	// This function is equivalent to setVisible(true).
    	//--------------------------------------------
    	//hello.show();//当创建一个窗口部件时,它是不可见的,你必须调用show让它可见   
    	quit.setVisible(TRUE);
    
    	return a.exec();//控制转给QT,在exec中,QT接收并处理用户和系统的事件并把它们传给适当的窗口部件
    	
    }


    1.QFont(“字体类型”,height, “磅数”)

    2.connect是静态函数,它把两个QObject对象单向连接起来,所有窗口部件都是QT对象,都基于QWidget,而QWidget基于QOject.

  • 相关阅读:
    BEC listen and translation exercise 44
    中译英12
    BEC listen and translation exercise 43
    中译英11
    BEC listen and translation exercise 42
    中译英10
    BEC listen and translation exercise 41
    中译英9
    BEC listen and translation exercise 40
    中译英8
  • 原文地址:https://www.cnblogs.com/hgy413/p/3693724.html
Copyright © 2011-2022 走看看