PDA

View Full Version : QThread problem



MrShahi
10th July 2008, 06:00
Hello Everyone
I have a little problem and hope you will help me
My problem is that I wana start my process in the thread the reason is that I m moving a widget over a widget on timeout event of QTimer but problem is this whenevr there start more than one process ,then the movement of widget start jerk so stop all these I wana move my widget using QThread .................
But I have no idea how do it ?????????:confused:
Please suggest me some hints;)

jpn
10th July 2008, 06:17
1) There is no need to execute a process in a thread. It is a different process, it doesn't block the current process unless you use blocking waitXXX() methods.
2) Touching GUI in a worker thread is prohibited.

MrShahi
10th July 2008, 06:44
Thanx for reply JPN ..........
But my problem is still remain.......
I just wana stop jerking or flikering of widget when there exist more than one process,,,,,,
what I do for it:confused:

jpn
10th July 2008, 06:56
Could you provide a bit more details what do you actually do and how you do it?

MrShahi
10th July 2008, 07:06
yes this my move.h file

#ifndef MOVE_H
#define MOVE_H
#include<QWidget>
#include"ui_move.h"
class Move : public QWidget,public Ui_Form
{

Q_OBJECT

public:
Move(QWidget *parent=0);
int x;;
int y;
int width;
public slots:

void moveWidget();

};
#endif
and this my move.cpp file




#include"move.h"
#include "ui_move.h"
#include<QDebug>
#include<QTimer>
#include<QtGui>
#include<QPoint>
Move::Move(QWidget *parent) : QWidget(parent)
{

setupUi(this);
x=950;
y=10;
int locx=1024*0/100;
int locy=768*80/100;
int w=1024*100/100;

int h=768*20/100;
QString si("Sonu Shahi is great Enjoy ");


this->setGeometry(locx,locy,w,h);

QLabel *label=new QLabel( si,widget);
label->setTextFormat (Qt::RichText );
QFont font("Helvetica", 72, QFont::Bold);
label->setFont(font);

QFontMetrics fm(font);
width = fm.width(si);
int pixelsHigh = fm.height();
qDebug()<<"size of si"<<si.size ()<<"width of font"<<width<<"hight"<<pixelsHigh;
label->show();
widget->setGeometry(950,55,width,pixelsHigh);
QTimer *timer = new QTimer;
connect(timer,SIGNAL(timeout()),this,SLOT(moveWidg et()));
timer->start(10);
QPalette palette;

QBrush brush(Qt::red,Qt::SolidPattern);

palette.setBrush(QPalette::Active, QPalette::Window, brush);
this->setPalette(palette);
label->setPalette(palette);
widget->setPalette(palette);
/**********************/
QPalette palette1;

QBrush brush1(Qt::yellow,Qt::SolidPattern);

palette1.setBrush(QPalette::Active, QPalette::WindowText, brush1);
//this->setPalette(palette);
label->setPalette(palette1);
//widget->setPalette(palette);
/*******************/

}
void Move::moveWidget()
{
QPoint m=widget->pos();
if(x<=-width)
x=950;

x=x-1;


widget->move(x,y);

}


I simply call this class in main .cpp and play it ......
and output is as good as I want .........
But whenever I embed this code into my movie player code where different movie are simultaniousely play within multiple widget this start jerking ...........thts why I m searching a logic or hint through which I stop jerking ...............
I think its enough for you ............................

MrShahi
11th July 2008, 12:57
Can anyone tell me how can smoothly play my scrollor...................
;)

MrShahi
15th July 2008, 12:28
Hello guys , I have solved my problems
...................;)
but again there is little bit problem ...................
i.e the widget which is moving , sometimes becomes jerky and after sometime it scroll smoothly ...............why I don't know ????????
If any one can help me I'll appericiate him..........
Thanks