标题:QT多线程编程,添加一个线程后,我的背景,图片都不显示了,救助!!!!!!
作者:wandersky
日期:2009-09-07 17:58
内容:
环境:板子为2410,arm-gcc-3.3.2QTE2.3.7
以下为mainwindow.cpp
#include "mainwindow.h"
#include "my_define.h"
#include "serialthread.h"
MyMainWindow :: MyMainWindow()
{
fd = open(MODEMDEVICE, O_RDWR | O_NOCTTY );
if (fdsetMinimumSize(320,240);
//this->setMaximumSize(320,240);
QPixmap image("background.jpg");
setBackgroundPixmap(image); //这个地方没有起作用呀
b1=new QPushButton("verygood",this);
QPalette newPalette=b1->palette();
newPalette.setColor(QColorGroup::ButtonText, Qt::red);
b1->setPalette(newPalette);
b1->setGeometry(30,140,120,40);
b1->setFont(QFont("Times",18,QFont::Bold));
b2=new QPushButton("yibangood",this);
QPalette pal = b2->palette();
pal.setColor(QColorGroup::Button, Qt::blue);
b2->setPalette(pal);
b2->setGeometry(180,140,120,40);
b2->setFont(QFont("Times",18,QFont::Bold));
b3=new QP ..
#1 [wandersky 09-07 18:01]
以下为main.cpp
#include
#include
#include
#include
#include
#include
#include
#include
#include "mainwindow.h"
int main(int argc,char ** argv)
{
QApplication a(argc,argv);
MyMainWindow w;
a.setMainWidget(&w);
w.show();
a.exec();
}
以下为serialthread.cpp
#include "my_define.h"
#include "serialthread.h"
#include "mainwindow.h"
#define _POSIX_SOURCE 1 /* POSIX compliant source */
volatile int STOP=FALSE;
int wait_flag=TRUE; /* TRUE while no signal received */
SerialThread::SerialThread(MyMainWindow *parent){
this->parent = parent;
}
void SerialThread::run()
{
int res;
struct termios oldtio,newtio;
char buf[255];
tcgetattr(parent->fd,&oldtio);
bzero(&newtio, sizeof(newtio)); /* clear struct for new port settings */
/*
BAUDRATE: Set bps rate. You could also use cfsetispeed and cfsetospeed.
CRTSCTS : output hardware flow control (only used if the cable has
all necessary lines. See sect. 7 of Serial−HOWTO)
CS8 : 8n1 (8bit,no parity,1 stopbit)
CLOCAL : local connection, no modem contol
CREAD : enable receiving characters
*/
newtio.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD;
/*
IGNPAR : ignore bytes with parity errors
ICRNL : map CR to NL (otherwise a CR input on the other computer
will not terminate input)
otherwise make device raw (no other input processing)
*/
newtio.c_iflag = IGNPAR | ICRNL;
/*
Raw output.
*/
newtio.c_oflag = 0;
/*
ICANON : enable canonical input
disable al ..
#2 [wandersky 09-07 18:02]
请高人指点!!!!!!!!
详细说明:当我把这两个文件"serialthread.h","serialthread.cpp文件删除之后,然后再把程序中有关"线程的变量删除,重新编译,我设置的背景图片就能够显示出来 ,我画的图片也能够显示出来,但是添加上"serialthread.h,"serialthread.cpp这两个文件之后就不能显示了,只能显示我的按钮。
#3 [speaker424 09-08 10:14]
我也遇到同样的问题,好像新的线程阻止了画面的显示
#4 [wandersky 09-08 11:15]
期待高手,给点提示,
上楼解决了吗??