#ifndef MOVE_H
#define MOVE_H
#include<QWidget>
#include"ui_move.h"
class Move
: public QWidget,
public Ui_Form
{
Q_OBJECT
public:
int x;;
int y;
int width;
public slots:
void moveWidget();
};
#endif
#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
To copy to clipboard, switch view to plain text mode
and this my move.cpp file
#include"move.h"
#include "ui_move.h"
#include<QDebug>
#include<QTimer>
#include<QtGui>
#include<QPoint>
{
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);
label->setTextFormat (Qt::RichText );
label->setFont(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);
connect(timer,SIGNAL(timeout()),this,SLOT(moveWidget()));
timer->start(10);
QBrush brush
(Qt
::red,Qt
::SolidPattern);
this->setPalette(palette);
label->setPalette(palette);
widget->setPalette(palette);
/**********************/
QBrush brush1
(Qt
::yellow,Qt
::SolidPattern);
//this->setPalette(palette);
label->setPalette(palette1);
//widget->setPalette(palette);
/*******************/
}
void Move::moveWidget()
{
if(x<=-width)
x=950;
x=x-1;
widget->move(x,y);
}
#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(moveWidget()));
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);
}
To copy to clipboard, switch view to plain text mode
Bookmarks