板子: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.h>
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 <qpushbutton.h>
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
// Construct loop through label and check box
loop_through_check = new QCheckBox( tr( "Loop through" ), this );
vbox->addWidget( loop_through_check );
// 加上下面这段
// Construct ok cancel buttons JYX_MODI add
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 );
// JYX_MODI add end
重新编译photoEdit便可.