www.cnblogs.com/ruiyqinrui

开源、架构、Linux C/C++/python AI BI 运维开发自动化运维。 春风桃李花 秋雨梧桐叶。“力尽不知热 但惜夏日长”。夏不惜,秋不获。@ruiY--秦瑞

python爬虫,C编程,嵌入式开发.hadoop大数据,桉树,onenebula云计算架构.linux运维及驱动开发.

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

1,进程条--向用户显示程序的当前状态,向用户提示该任务需要多长时间才能够完成.

Qt-ProgressBar创建进程条,QProgressBar,为了使进程条担当起进程指示功能,需要执行定义进程条的刷新时间

paint->drawText(20,20-左上角相对于父部件的位置,260,60--字体图形的长度及宽度,AlignCenter--对齐方式,"Font:Arial,Size:16,Style:Bold")

QPainter绘图函数,paintEvent()函数begine()

end();

ellipse(),circle,drawEllipse()函数,paint->setPen(blue,4,QPen::SolidLine);

paint->drawEllipse(20,20,210,160);园,椭圆 距离窗口左上角像素数,宽度-高度

QPainter绘图函数---圆角矩形QPainter::drawRoundRect()

paint->setPen(Qpen(red,4,Qpen::SolidLine));

paint->drawRoundRect(20,20,210,160,50,50);最后两个参数决定角的圆度,0-99,99之最园.

2,pie饼图扇形QPainter::drawPie()

paint->setPen(QPPen(green,4,QPen::SolidLine));

paint->drawPie(20,20,210,160,0,500);后两个参数定义园的样式,0起始角度,500扇形弧线长度,最后两个参数不表示度,而是表示1度的16份之一,一个园就表示5760(16 * 360)

3,绘制,

paint->setPen(QPen(green,4,QPen::SolidLine));

paint->drawChord(20,20,210,160,500,10000);

paint->setPen(QPen(green,4,QPen::SolidLine));

paint->drawArc(20,20,210,160,500,10000);

paint->setPen(QPen(green,4,QPen::SolidLine));

paint->drawQuadBezier(QPointArray(QRect(20,20,210,160)));

drakYellow,drakMagenta,drakCyan,drakBlue,gray,magentablack  drak,dark;

管理颜色,指定颜色

Qt指定颜色,RGB(red,green,blue),HSV(色度/饱和度、纯度)

QPrinter::getPrinter();

QPrinter print;

int proceed = print_setup();

if (proceed == true)

{

//start printing

//(start drawing to the QPrinter object)

}

else

{

//Abort

}

理解Qt对话框

QColorDialog类唯一的一个函数QColorDialog::getColot()显示颜色选择对话框,该函数返回所选中的桉树

2,文本对话框

用于选则文件的对话框

ile.cpp: In constructor ‘MyMainWindow::MyMainWindow()’:
file.cpp:19:44: error: no matching function for call to ‘QFileDialog::getOpenFileName(const char [5], const char [2])’
  file = fdialog->getOpenFileName("/opt","*");
                                            ^
file.cpp:19:44: note: candidate is:
In file included from /opt/Qt5.4.1/5.4/gcc_64/include/QtWidgets/QFileDialog:1:0,
                 from file.cpp:3:
/opt/Qt5.4.1/5.4/gcc_64/include/QtWidgets/qfiledialog.h:200:20: note: static QString QFileDialog::getOpenFileName(QWidget*, const QString&, const QString&, const QString&, QString*, QFileDialog::Options)
     static QString getOpenFileName(QWidget *parent = 0,
                    ^
/opt/Qt5.4.1/5.4/gcc_64/include/QtWidgets/qfiledialog.h:200:20: note:   no known conversion for argument 1 from ‘const char [5]’ to ‘QWidget*

Qt 打开文件的默认路径 QFileDialog::getOpenFileName()

为了说明QFileDialog::getOpenFileName()函数的用法,还是先把函数签名放在这里:
 
QString QFileDialog::getOpenFileName (
          QWidget * parent = 0,
          const QString & caption = QString(),
          const QString & dir = QString(),
          const QString & filter = QString(),
          QString * selectedFilter = 0,
          Options options = 0 )
 
第一个参数parent,用于指定父组件。注意,很多Qt组件的构造函数都会有这么一个parent参数,并提供一个默认值0;
 
第二个参数caption,是对话框的标题;
 
第 三个参数dir,是对话框显示时默认打开的目录,"." 代表程序运行目录,"/" 代表当前盘符的根目录(Windows,Linux下/就是根目录了),也可以是平台相关的,比如"C:\\"等;例如我想打开程序运行目录下的Data 文件夹作为默认打开路径,这里应该写成"./Data/",若想有一个默认选中的文件,则在目录后添加文件名即可:"./Data /teaser.graph"
 
第 四个参数filter,是对话框的后缀名过滤器,比如我们使用"Image Files(*.jpg *.png)"就让它只能显示后缀名是jpg或者png的文件。如果需要使用多个过滤器,使用";;"分割,比如"JPEG Files(*.jpg);;PNG Files(*.png)";
 
第五个参数selectedFilter,是默认选择的过滤器;
 
第六个参数options,是对话框的一些参数设定,比如只显示文件夹等等,它的取值是enum QFileDialog::Option,每个选项可以使用 | 运算组合起来。
 
如果我要想选择多个文件怎么办呢?Qt提供了getOpenFileNames()函数,其返回值是一个QStringList。你可以把它理解成一个只能存放QString的List,也就是STL中的list<string>。
3,字体选则对话框
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -I. -I/opt/Qt5.4.1/5.4/gcc_64/include -I/opt/Qt5.4.1/5.4/gcc_64/include/QtWidgets -I/opt/Qt5.4.1/5.4/gcc_64/include/QtGui -I/opt/Qt5.4.1/5.4/gcc_64/include/QtCore -I. -I/opt/Qt5.4.1/5.4/gcc_64/mkspecs/linux-g++ -o front.o front.cpp
g++ -Wl,-O1 -Wl,-rpath,/opt/Qt5.4.1/5.4/gcc_64 -Wl,-rpath,/opt/Qt5.4.1/5.4/gcc_64/lib -o font front.o   -L/opt/Qt5.4.1/5.4/gcc_64/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread
4,message对话框
消息框上边显示的文本字符串--窗口标题,消息框内显示的文本字符串--实际消息
mbox = new QMessageBox("Proceed?","Do you want to proceed?",QMessageBox::Cirtical--图标,)
QMessageBox::NoIcon不显示任何图标,QMessageBox::Information,Waning,Cirtical
QMessageBox::Ok | QMessageBox::Default,QMessageBox::Cancel | QMessage::Escape 两个按钮,一个是默认的enter 和Escape空格按钮,最后一个参数是第三个按钮; QMessageBox::yes,abort retry ignore
5,进度对话框
进度对话框用于将程序的当前状态--与进度条一样通知用户,进度条对话框与进度条间区别 能否与用户间进行交互
constructor
6,创建用户对话框 QDialog(所有对话框基类),QTabDialog(选项卡对话框)
对话框类型---模式对话框(启动自己的事件循环,对话框关闭之前会阻塞程序的其余事件)--非模式对话框
QDialog::setCaption()函数用于设置对话框窗口标题
QDialog::accept(),QDialog::reject(),QDialog::done()QDialog自动调整窗口大小适应子部件
 
posted on 2015-03-26 17:45  秦瑞It行程实录  阅读(529)  评论(0编辑  收藏  举报
www.cnblogs.com/ruiyqinrui