QT设置字体与颜色
2017-08-04 16:11
309 查看
头文件:
#include <QFont>
#include <QFontDialog>
#include <QColor>
#include <QColorDialog>
user interface complier
QColor
QFont
QFontDialog
QDataTime
程序代码:
//设置字体
void MainWindow::setFontSlot()
{
//get user select Font
bool ok;
QFont font = QFontDialog::getFont(&ok,this);
if(ok)
{
ui->textEdit->setFont(font);
//font is set to the font the user selected
}
else
{
QMessageBox::information(this,"Error Message","Eoor Set Font!!!")
//the user canceld the dialog;font is set to the default
//application font,QApplication::font()
}
}
//设置颜色
void MainWindow::setColorSlot()
{
QColor color = QColorDialog::getColor(Qt::red,this); //设置初始化颜色为红色
if(color.isValid())
{
ui->textEdit->setTextColor(color);
}
else
{
QMessageBox::information(this,"Error Message","Color is Invalid");
return;
}
}
#include <QFont>
#include <QFontDialog>
#include <QColor>
#include <QColorDialog>
user interface complier
QColor
QFont
QFontDialog
QDataTime
程序代码:
//设置字体
void MainWindow::setFontSlot()
{
//get user select Font
bool ok;
QFont font = QFontDialog::getFont(&ok,this);
if(ok)
{
ui->textEdit->setFont(font);
//font is set to the font the user selected
}
else
{
QMessageBox::information(this,"Error Message","Eoor Set Font!!!")
//the user canceld the dialog;font is set to the default
//application font,QApplication::font()
}
}
//设置颜色
void MainWindow::setColorSlot()
{
QColor color = QColorDialog::getColor(Qt::red,this); //设置初始化颜色为红色
if(color.isValid())
{
ui->textEdit->setTextColor(color);
}
else
{
QMessageBox::information(this,"Error Message","Color is Invalid");
return;
}
}
相关文章推荐
- Qt5.9设置pushButton按钮背景色和字体颜色
- 如何使用Qt4,设置QLabel中字体的颜色。
- 【QT】 QLabel设置字体大小和颜色
- QT设置QLabel中字体的颜色
- Qt设置QLabel中字体的颜色
- QT QTableView用法小结(设置单元格字体颜色,文本字体...)
- QT 文字字体和颜色设置
- Qt下设置QLabel字体的大小和颜色
- Qt 设置QLabe中字体的颜色
- 使用Qt 4如何设置QLabe中字体的颜色
- QT设置QPushButton的Text字体颜色
- Qt 设置QLabe中字体的颜色
- 记录我学Qt的点点滴滴(一、获取文件路径、设置字体、颜色)
- Qt4设置QLabel中字体的颜色
- QT中设置字体和更改字体颜色
- QT中字体和颜色的设置
- QT QLabel设置字体的颜色
- 使用Qt 设置QLabe中字体的颜色
- Qt设置QTextEdit和QLabel的字体颜色
- 使用Qt 4如何设置QLabe中字体的颜色