Exemplo n.º 1
0
KbfxSpinxScrollBar::KbfxSpinxScrollBar ( QWidget * parent, const char *name, int type ) :
		QWidget ( parent, name )
{
    if (type == 0){
	m_normal = ( *KbfxPlasmaPixmapProvider::pixmap ( "scrollnormal" ) );
    } else {
        m_normal = ( *KbfxPlasmaPixmapProvider::pixmap ( "scrollnormalbot" ) );
    }
        QImage _tmp_img = m_normal.convertToImage();
	_tmp_img = _tmp_img.smoothScale ( ConfigInit().m_itemView_w, m_normal.height (),QImage::ScaleFree );
	m_normal = QPixmap ( _tmp_img );

	this->resize ( m_normal.width (), m_normal.height () );

	_x = this->x () /40;
	_y = this->y ();
	w = this->width () / 40;
	h = this->height () / 2;
	_x += ( this->width () - w ) / 2;
	_y += ( this->height () - h ) / 2;
	m_triAngle = QPointArray ( 3 );
	m_dir = DOWN;
	m_timer = new QTimer ( this,"ScrollTimer" );
	connect ( m_timer,SIGNAL ( timeout() ),this,SLOT ( timeoutslot() ) );
	m_pressed = false;

}
Exemplo n.º 2
0
gamewidget::gamewidget(QWidget *parent) :
    QDialog(parent)
{
    //background
    this->setAutoFillBackground(true);
    this->resize(391,220);
    this->setWindowTitle("snack");
    QPalette  palette;
    palette.setBrush(QPalette::Background,QBrush(QPixmap(":/new/prefix1/img/green.jpg")));
    this->setPalette(palette);
    //button
    left_button = new QPushButton("Left",this);
    left_button->setGeometry(QRect(260,70,40,30));
    right_button = new QPushButton("Right",this);
    right_button->setGeometry(QRect(340,70,40,30));
    up_button = new QPushButton("Up",this);
    up_button->setGeometry(QRect(300,40,40,30));
    down_button = new QPushButton("Down",this);
    down_button->setGeometry(QRect(300,70,40,30));
    start_button = new QPushButton("Start",this);
    start_button->setGeometry(270,120,50,30);
    return_button = new QPushButton("Return",this);
    return_button->setGeometry(330,120,50,30);
    //signal and slot
    connect(left_button,SIGNAL(clicked()),this,SLOT(left_click()));
    connect(right_button,SIGNAL(clicked()),this,SLOT(right_click()));
    connect(up_button,SIGNAL(clicked()),this,SLOT(up_click()));
    connect(down_button,SIGNAL(clicked()),this,SLOT(down_click()));
    connect(start_button,SIGNAL(clicked()),this,SLOT(start_click()));
    connect(return_button,SIGNAL(clicked()),this,SLOT(return_click()));
    //key singnal
    connect(this,SIGNAL(UpSignal()),this,SLOT(up_click()));
    connect(this,SIGNAL(DownSignal()),this,SLOT(down_click()));
    connect(this,SIGNAL(LeftSignal()),left_button,SLOT(click()));
    connect(this,SIGNAL(RightSignal()),right_button,SLOT(click()));
    //auto update
    timer = new QTimer(this);
    connect(timer,SIGNAL(timeout()),this,SLOT(timeoutslot()));
    //rand seed
    QTime t;
    t= QTime::currentTime();
    qsrand(t.msec()+t.second()*1000);
    //head
    snake[0][0] = qrand()%ROW;
    snake[0][1] = qrand()%COL;
    //data init
    foodcount = 0;
    suicide = false;
    thesame = false;
    speed = 300;
    sound_eat = new QSound(":/sounds/eating.wav",this);
    sound_die = new QSound(":/sounds/gameover.wav",this);
    foodx = qrand()%ROW;
    foody = qrand()%COL;
    while (foodx==snake[0][0]&&foody==snake[0][1]) {
        foodx = qrand()%ROW;
        foody = qrand()%COL;
    }
    directioin = qrand()%4;
}
Exemplo n.º 3
0
int MyDialog::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QDialog::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: enter(); break;
        case 1: showTime(); break;
        case 2: timeoutslot(); break;
        case 3: showPicture(); break;
        case 4: sendMsg(); break;
        case 5: recvMsg(); break;
        case 6: error(); break;
        default: ;
        }
        _id -= 7;
    }
    return _id;
}