#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
#include <QPushButton>
#include <QLineEdit>
#include <QFontDialog>
#include <QGridLayout>
class Dialog : public QDialog
{
Q_OBJECT
public:
Dialog(QWidget *parent = nullptr);
~Dialog();
private:
QGridLayout *glayout;
QPushButton *fontbutton;
QLineEdit *fontlineedit;
private slots:
void dispFontFunc();
};
#endif // DIALOG_H
#include "dialog.h"
Dialog::Dialog(QWidget *parent)
: QDialog(parent)
{
setWindowTitle("字体对话框测试");
glayout=new QGridLayout(this);
fontbutton=new QPushButton("调用字体对话框");
fontlineedit=new QLineEdit;
fontlineedit->setText("零声教育");
glayout->addWidget(fontbutton,0,0);
glayout->addWidget(fontlineedit,0,1);
connect(fontbutton,SIGNAL(clicked()),this,SLOT(dispFontFunc()));
}
Dialog::~Dialog()
{
}
void Dialog::dispFontFunc()
{
bool isbool;
QFont font=QFontDialog::getFont(&isbool);
if(isbool)
{
fontlineedit->setFont(font);
}
}
55-Qt字体对话框实战
最新推荐文章于 2024-11-08 15:01:32 发布