QT常见的窗口部件

设置QT应用程序图标

  • 1.将ico文件加入源文件目录
  • 2.pro文件中加入下面模块
 RC_FILE = myapp.rc

-3.源目录中添加myappico.rc代码

IDI_ICON1               ICON    DISCARDABLE     "myappico.ico"

使msvc使mingwqmakepro

 RC_ICONS = myappico.ico

WindowsqtSettingtheApplicationIcon

设置显示中文

#include <QTextCodec>
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));

QT使tr()使QString()

命令行编译

(在含有UI文件中需要使用uic工具)

uic XXXX.ui

1.源文件一定要设置utf-8编码,不然中文乱码
2.生成pro工程文件

qmake -project QT+=widgets

3.编译Makefile

qmake

4.make来编译

mingw32-make

设置窗口类型

QWidget::QWidget(QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags())

parentfFramelessWindowHintWindowStaysOnTopHintSplashScreen

QRect geometry=widget.geometry();
QRect frame=widget.frameGeometry();

QRectxygeometryframeGeometry

QT,QDebug

qDebug("x:%d",x);
qDebug()<<"geometry:"<<geometry<<"frame:"<<frame;

QT

对话框

1.模态对话框:

   QDialog dialog(this);
   dialog.exec();
   //或者
    QDialog  *dialog=new QDialog(this);
    dialog->setModal(true);
    dialog->show();

2.非模态对话框:

    QDialog  *dialog=new QDialog(this);
    dialog->show();


setModal(true)setWindowModality()

ALT+Enter

slot,connect,"on"connect

accept()QDialog::Accepted

close()show()

,便

1.:QCloorDialog
2.:QFileDialog
3.:QFontDialog
4.:QInputDialog
5.:QMessageBox
6.:QProgressDialog
7.:QErrorMessage
8.:QWizard
9.():QPageSetupDialog
8.(:QPrintDialog
8.:QPrintPreviewDialog

QFrame
QAbstractScrollArea Qt中带有Abstract类的都是抽象类,不能直接使用。
以下类都是QFrame的子类,继承他的属性
1.QLabel
2.QLCDNumber
3.QStackedWidget
4.QToolBox

QAbstractButton
1.QPushButton
2.QCheckBoxQRadioButtonQGroupBox

QLineEdit
1.4echomode
2.inputMask
3.使validator
4.使QCompleter

QAbstractSpinBox
1.QDateTimeEdit
2.QSpinBox
3.QDoubleSpinBox


QAbstractSlider
1.QScrollBar
2.QSlider
3.QDial

猜你喜欢

转载自blog.csdn.net/qq_31208451/article/details/78797056