qt repaint 用法_qt的repaint的问题
qt的repaint的问题
在网上找了个qt刷屏的程序,
下面是主要代码,在main函数中调用showSlot程序,以便读取图形文件,但是遇到了奇怪的问题,
程序在linux PC端运行良好,用的是usr/lib/qt-3.1
但是在自己编译的qt embedded 就不行,显示每次都进入了paintEvent中,但是屏幕上就是没有显示,连窗口都没有,而且不论在主函数中调用了多少次显示图像,都只显示最后一张图。
请大家帮忙看看可能是怎么回事。
#include "form1.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
/*
* Constructs a Form1 as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*/
Form1::Form1( QWidget* parent, const char* name, WFlags fl )
: QWidget( parent, name, fl )
{
if ( !name )
setName( "Form1" );
pushButton2 = new QPushButton( this, "pushButton2" );
pushButton2->setGeometry( QRect( 230, 10, 91, 21 ) );
pushButton1 = new QPushButton( this, "pushButton1" );
pushButton1->setGeometry( QRect( 30, 10, 81, 21 ) );
languageChange();
resize( QSize(720, 480).expandedTo(minimumSizeHint()) );
clearWState( WState_Polished );
// signals and slots connections
connect( pushButton2, SIGNAL( released() ), this, SLOT( close() ) );
// connect( pushButton1, SIGNAL( released() ), this, SLOT( showSlot() ) );
}
/*
* Destroys the object and frees any allocated resources
*/
Form1::~Form1()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void Form1::languageChange()
{
setCaption( tr( "Form1" ) );
pushButton2->setText( tr( "&Quit" ) );
pushButton1->setText( tr( "&Show" ) );
}
bool Form1::showSlot(const char * newfilename)
{
bool ok = false;
ok = image.load((QString)newfilename, 0); //step 2
if (!ok)
{
printf("load image failed\n");
return false;
}
else printf("load %s success\n",newfilename);
ok = pm.convertFromImage(image, 0); //step 3
if (!ok)
{
printf("convert from image to a pixmap failed\n");
return false;
}
repaint();
return FALSE;
}
void Form1::paintEvent(QPaintEvent *pe)
{
printf("enter paint function\n");
QPainter painter(this);
painter.setClipRect(pe->rect());
painter.drawPixmap(0, 0, pm); //step 4
}
qt repaint 用法_qt的repaint的问题相关推荐
- qt repaint 用法_Qt重绘之update,repaint详解
Qt里面的重绘和Windows编程里面的重绘差不多.但是Qt的重绘更有特色,更加智能. 在讲之前,先说说paintEvent() paintEvent()是一个虚函数槽(slot),子类可以对父类的p ...
- qt repaint 用法_Qt 中update()和repaint()的区别
void QWidget::repaint ( int x, int y, int w, int h, bool erase = TRUE ) [槽] 通过立即调用paintEvent()来直接重新绘 ...
- qt repaint 用法_Qt重绘之update,repaint详解(转)
Qt里面的重绘和Windows编程里面的重绘差不多.但是Qt的重绘更有特色,更加智能. 在讲之前,先说说paintEvent() paintEvent()是一个虚函数槽(slot),子类可以对父类的p ...
- qt repaint 用法_Qt常用函数 记录(update erase repaint 的区别)
一界面重载函数 使用方法: 1在头文件里定义函数 protected: void paintEvent(QPaintEvent *event); 2 在CPP内直接重载 void ---------- ...
- qt repaint 用法_qt的update与repaint
一直搞不明白,qt的update与repaint的区别.虽然文档上说得貌似很明了了.但是,不看看源码,用着用着就迷糊了.今天看了下下相关的源码,记下自己的一点心得的. 1.update到paintEv ...
- qt repaint 用法_关于Qt 中update()和repaint()的区别
void QWidget::repaint ( int x, int y, int w, int h, bool erase = TRUE ) [槽] 通过立即调用paintEvent()来直接重新绘 ...
- Qt重绘之update,repaint详解
Qt里面的重绘和Windows编程里面的重绘差不多.但是Qt的重绘更有特色,更加智能. 在讲之前,先说说paintEvent() paintEvent()是一个虚函数槽(slot),子类可以对父类的p ...
- qt 复制字符串_Qt字符串处理 QString用法总结(一)
下面分两种情况进行说明. 一.QString 转换为 char * 将 QString 转 char *,需要用到 QByteArray 类,QByteArray 类的说明详见 Qt 帮助文档. 因为 ...
- qt 复制字符串_Qt字符串处理 QString用法总结(二)
C++语言提供了两种字符串的实现:C风格的字符串,以'\0'结尾;std::string,即标准模版库中的类.Qt则提供了自己的字符串实现:QString,QString不用担心内存分配以及关于'\0 ...
最新文章
- vscode 搭建go开发环境的13个插件的安装
- 无线鼠标接收器对码软件_接收器太小容易丢 这几招记好就不怕
- STL之Iterator(迭代器)
- mysql的三大特性_【mysql】Innodb三大特性之double write
- 注意指针修饰符的准确含义
- 06构造方法和文件读取
- 为什么中国人穷得只剩房子
- [bzoj] 1257 余数之和sum || 数论
- 数据库工作笔记018---Windows下mysql安装_服务无法启动没有报告解决
- 构造方法与构造代码块的区别
- Linux Centos7 测试硬盘IO速度
- 飞鸽传书2007绿色版还需要遵循些基本的原则
- 从ToC到ToB,疫情给我们的影响是什么?
- 腾讯实习生面试经历分享
- 云数智驱动数据高速增长,浪潮存储提供EB级容量扩展
- Thinkphp5生成二维码
- Android Camera开发系列:设置对焦模式模式
- 器件选型电源篇-AC/DC电源模块选型及性能测试
- AI人工智能外呼机器人测试项目经历
- STM32F4移植EMWIN(RA8875驱动显示屏)
热门文章
- Mac Ideal快捷键
- 湖北武汉电动机保护器公司哪家好_电动机保护器-上海硕吉电器_新浪博客
- 西部数码 425 Security: Bad IP connecting
- Android Studio官方视频教程笔记
- 圈圈叉叉/井字棋/TicTacToe——C/C++实现
- 台达PLC ES与欧姆龙E5CC温控器485通讯程序带注释,并附送昆仑通态和威纶通触摸屏程序,有接线方式,设置
- 49	 Group Anagrams
- win10一直蓝屏!一直是这个代码,ntoskrnl.exe导致,要废了。。
- 递归优化为递推:数组/临时变量-计算兔子(斐波那契数列)
- 百度地图----导航