板子:helper2416 qtopia2/3 作者:帅得不敢出门 c++哈哈堂:31843264
例子1: 修改工具栏, 比如添加一个关闭按钮
修改qtopia-2.2.0/qtopia/src/libraries/mediaplayer/mediaselectorwidget.cpp
class MediaSelectorWidgetPrivate {
中添加
Action *tbQuit;
构造函数中
MediaSelectorWidget::MediaSelectorWidget
d->tbAdd = new Action( this, tr( "Add to Category..." ), "categorize",this, SLOT(categorize()) );下一行添加
d->tbQuit = new Action( this, tr( "Quit" ), "close", qApp, SLOT(quit()) );
d->tbAdd->addTo(contextMenu); 下一行添加
d->tbQuit->addTo(contextMenu);
d->tbDown->addTo( d->bar ); 下一行添加
d->tbQuit->addTo( d->bar );
然后在qtopia/pics/icons/ 下的各文件夹加close.png就行了.
注意修改libraries/mediaplayer 下的文件会同时影响videos 与music
例2 播放音视频的窗口中滑动条与时间控件的右边添加关闭按钮
qtopia/src/libraries/mediaplayer/controlwidgetbase.h中添加
#include
QPushButton *closeBtn;
qtopia/src/libraries/mediaplayer/controlwidgetbase.cpp 中
1
-
ControlWidgetBase::ControlWidgetBase( QWidget* parent, const QString &skinPath,
-
const QString &type, const char* name ) :
-
QWidget(parent, name), buttonCount(0), slider(Qt::Horizontal, this),
-
time(this), sliderBeingMoved(false), volumeTimeout(this), drawVolume(false)
-
{
-
setCaption( tr("Media Player") );
-
-
closeBtn = new QPushButton( tr("close"), this);
2
-
connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
-
connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
-
-
connect( closeBtn, SIGNAL( pressed() ), this, SLOT( close() ) );
3
-
imgButtonMask.fill( 0 );
-
-
int closeBtnW = 48;
-
int y1 = h - timeHeight - 2 * border;
-
int x2 = w - timeWidth - border - cornerWidgetWidth - closeBtnW - border;
-
QRect sliderGeometry( border, y1, x2 - 2*border, timeHeight );
-
QRect timeGeometry( x2, y1, timeWidth, timeHeight );
-
QRect closeBtnGeometry( x2 + timeWidth + border, y1, closeBtnW, timeHeight);
-
getRect(cfg, skinType+"_slider", sliderGeometry, w, h);
-
getRect(cfg, skinType+"_time", timeGeometry, w, h);
-
-
slider.setGeometry(sliderGeometry);
-
time.setGeometry(timeGeometry);
-
closeBtn->setGeometry(closeBtnGeometry);
然后先编译libmediaplayer.so
再分别编译musi 与videos, 如果不重新编译运行会出现段错误.
就可以了.
例3: 给photoEdit的sider_show窗口添加 确定 与取消两个按钮
qtopia/src/applications/photoedit/slideshow/slideshowdialog.h
包含头
#include
-
private:
-
QLabel *slide_length_label;
-
QSlider *slide_length_slider;
-
QCheckBox *display_name_check, *loop_through_check;
-
-
QPushButton *ok_button, *cancel_button;
qtopia/src/applications/photoedit/slideshow/slideshowdialog.cpp
-
-
loop_through_check = new QCheckBox( tr( "Loop through" ), this );
-
vbox->addWidget( loop_through_check );
-
nbsp;
-
-
-
QHBoxLayout *hbox = new QHBoxLayout;
-
ok_button = new QPushButton( tr( "Ok" ), this );
-
cancel_button = new QPushButton( tr( "Cancel" ), this );
-
connect( ok_button, SIGNAL( pressed() ), this, SLOT( accept() ) );
-
connect( cancel_button, SIGNAL( pressed() ), this, SLOT( reject() ) );
-
hbox->addWidget( ok_button );
-
hbox->addWidget( cancel_button );
-
vbox->addLayout( hbox );
-
重新编译photoEdit便可.
阅读(1514) | 评论(0) | 转发(0) |