Qt标准对话框之QFontDialog

//这里简单介绍用法

public slots:
    void FontDlg();
private:
    QLineEdit *line;

//构造函数

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    resize(600,600);
    QPushButton *btn = new QPushButton(tr("修改字体"),this);
    btn->move(200,200);
    line = new QLineEdit(this);
    line->move(200,150);
    connect(btn,&QPushButton::clicked,this,&MainWindow::FontDlg);
}

FontDlg

void MainWindow::FontDlg()
{
    bool ok;
    QFont font = QFontDialog::getFont(&ok,this);
    if(ok) line->setFont(font);
}

你可能感兴趣的:(Qt)