qt slider scroll bar 进度条 自定义(通过style sheet)

void MediaPlay::createProgressBar()
{
   mVideoProgress = new CMPProgress(this, 6.0, 6.0, 16.0, 12.0);
   mVideoProgress->setBackgroundImage(QImage("resources/0.png"));

   //just do some test at first
   mVideoProgress->setRange(0, 1000);
   mVideoProgress->setValue(0);

   //add a QSlider widget, started
   mPlaySlider = new QSlider(Qt::Horizontal, this);
   mPlaySlider->setStyleSheet(QString::fromUtf8("QSlider{/n"
      "background: transparent;/n"
      "}/n"
      "/n"
      "QSlider::groove:horizontal {/n"
      "     border: none;/n"
      "     margin: 0px 0px 0px 0px;/n"
      "     background: transparent;/n"
      "}/n"
      "/n"
      "/n"
      "QSlider::handle:horizontal{/n"
      " border:none;/n"
      " background:transparent;/n"
      "    width:70px;/n"
      "    height:47px;/n"
      "    image:url(resources/1.png);/n"
      "/n"
      "}/n"
      "/n"
      "QSlider::handle:horizontal:pressed{/n"
      "    image:url(resources/2.png);/n"
      "/n"
      "}/n"
      "/n"
      "QSlider::sub-page:horizontal {/n"
      "    background-position: left center;/n"
      "    background-repeat: repeat-x;/n"
      " }"));
   mPlaySlider->setGeometry(138, 354, 560, 47);
   mPlaySlider->setRange(0, 1000);
   mPlaySlider->setValue(0);
   mPlaySlider->setDisabled(true);

//   connect(mPlaySlider, SIGNAL(sliderPressed()), this, SLOT(silderPressSeekVideo()));
//   connect(mPlaySlider, SIGNAL(valueChanged(int)), this, SLOT(silderSeekVideo(int)));
 //  connect(mPlaySlider, SIGNAL(sliderReleased()), this, SLOT(silderReleaseSeekVideo()));
   //ended

   mTimer = new QTimer(this);
   connect(mTimer, SIGNAL(timeout()), this, SLOT(advanceProgressBar()));
   mTimer->start(1000);
   mTimer->stop();
}

 

说明:http://doc.qt.nokia.com/4.6-snapshot/stylesheet-examples.html

你可能感兴趣的:(image,url,qt,border,scroll,Signal)