上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 25 下一页
#include #include #includeusing namespace std; int utf8togb2312(const char *sourcebuf,size_t sourcelen,char *destbuf,size_t destlen) { iconv_t cd; if( (cd = iconv_open("gb2312","utf-8")) ==0 ) return -1; memset(destbuf,0,destlen); const char **source = &sourcebuf; char **dest Read More
posted @ 2014-02-26 12:36 星语海蓝 Views(9796) Comments(0) Diggs(0) Edit
在Qt中设置widget背景颜色或者图片方法很多种:重写paintEvent() , 调色板QPalette , 样式表setStyleSheet等等。 但是各种方法都有其注意事项,如果不注意则很容易陷入麻烦中。1:setStyleSheet() 这个函数我一直很喜欢使用,因为只要写一句就可以实现效果,比其他方法都简单,但是其却有一个很值得注意的地方,也就是这个地方让我大吃苦头。 亦即:①:该函数只能用于设置有父窗口的子窗口的背景!如果一个窗口没有子窗口,则无法使用该函数来设置背景颜色或图 片!! ②:同时:对于一个父窗口而言:如果我们用setStyleShette设置了其样式,而对于其子窗口 Read More
posted @ 2014-01-10 14:10 星语海蓝 Views(2837) Comments(0) Diggs(0) Edit
Qt4.2开始引入了GraphicsView框架用来取代Qt3中的Canvas模块,并在很多地方作了改进,GraphicsView框架实现了模型-视图结构的图形管理,能对大量图元进行管理,支持碰撞检测,坐标变换和图元组等多种方便的功能。GraphicsView中增强的表现系统可以利用Qt4绘图系统的反锯齿,OpenGL工具来改善绘图性能,GraphicsView支持事件传播体系结构,可以利用图元在场景(scene)中的到提高了一倍的精确交互能力,图元能够处理键盘事件,鼠标按下,移动,释放,双击事件,也能跟踪鼠标的移动,在GraphicsView框架中,通过BSP(二元空间划分树)来提供快速的图 Read More
posted @ 2014-01-07 11:54 星语海蓝 Views(9040) Comments(0) Diggs(0) Edit
首先,给出基类animal和子类fish [cpp]view plaincopy//==============================================================//animal.h////begin:2012-06-30//author:zwq//describe:非虚函数情况下,将子类指针赋给积累指针,验证最终调用//基类函数还是子类函数。//==============================================================#ifndefANIMAL_H#defineANIMAL_H//======== Read More
posted @ 2014-01-07 11:16 星语海蓝 Views(9290) Comments(0) Diggs(3) Edit
【转自】:http://blog.csdn.net/rolland1989/article/details/5754575QWidget及其子类都可有右键菜单,因为QWidget有以下两个与右键菜单有关的函数:Qt::ContextMenuPolicy contextMenuPolicy () constvoid setContextMenuPolicy ( Qt::ContextMenuPolicy policy )Qt::ContextMenuPolicy 枚举类型包括:Qt::DefaultContextMenu, Qt::NoContextMenu, Qt::PreventContex Read More
posted @ 2014-01-07 10:09 星语海蓝 Views(13991) Comments(0) Diggs(0) Edit
1.拖动模式在QGraphicView中提供了三种拖动模式,分别是:QGraphicsView::NoDrag:忽略鼠标事件,不可以拖动。QGraphicsView::ScrollHandDrag:光标变为手型,可以拖动场景进行移动。QGraphicsView::RubberBandDrag:使用橡皮筋效果,进行区域选择,可以选中一个区域内的所有图形项。我们可以利用setDragMode()函数进行相应设置。 Read More
posted @ 2014-01-06 17:07 星语海蓝 Views(3185) Comments(0) Diggs(0) Edit
Graphics View提供了一个界面,它既可以管理大数量的定制2D graphical items,又可与它们交互,有一个view widget可以把这些项绘制出来,并支持旋转与缩放。这个柜架也包含一个事件传播结构,对于在scene中的这些items,它具有双精度的交互能力。Items能处理键盘... Read More
posted @ 2014-01-02 17:28 星语海蓝 Views(114080) Comments(2) Diggs(4) Edit
总结(-)1> 定时器的使用QTimer*timer=newQTimer(this);connect(timer,SIGNAL(timeout()),this,SLOT(update())); // 设置定时器回调函数timer->start(1000); // 启动定时器2> 得到系统当前时间QTimetime=QTime::currentTime();time.hour();time.minute();time.second();time.msec();3> 窗口 widget 相关setWindowTitle(tr("My Title"));/ Read More
posted @ 2014-01-02 14:45 星语海蓝 Views(5769) Comments(1) Diggs(1) Edit
QT提供了一个成熟的属性系统,但是作为一个跨平台的且与编译器无关的库,qt不依赖于非标准的编译器功能例如__propertyor[property];QT的强大之处在于它可以支持任何标准的c++编译器。 QT是基于Meta-Object System(元对象)和signals and slots(信号槽)的.Q_PROPERTYQ_PROPERTY()是一个宏,用来在一个类中声明一个属性property,由于该宏是qt特有的,需要用moc进行编译,故必须继承于QObject类。[cpp]view plaincopyQ_PROPERTY(typenameREADgetFunction[WRITE Read More
posted @ 2013-12-24 11:03 星语海蓝 Views(9495) Comments(0) Diggs(0) Edit
QT内置的ICON资源保存在QStyle类里。可以通过成员函数QStyle::standardIcon来获取。保存的icon有:enum QStyle::StandardPixmapThis enum describes the available standard pixmaps. A standard pixmap is a pixmap that can follow some existing GUI style or guideline.ConstantValueDescriptionQStyle::SP_TitleBarMinButton1Minimize button on ti Read More
posted @ 2013-12-19 15:03 星语海蓝 Views(991) Comments(0) Diggs(0) Edit
上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 25 下一页