Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4462495
  • 博文数量: 356
  • 博客积分: 10458
  • 博客等级: 上将
  • 技术积分: 4734
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-24 14:59
文章分类

全部博文(356)

文章存档

2020年(17)

2019年(9)

2018年(26)

2017年(5)

2016年(11)

2015年(20)

2014年(2)

2013年(17)

2012年(15)

2011年(4)

2010年(7)

2009年(14)

2008年(209)

分类: 嵌入式

2013-01-16 09:55:31

板子: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


  1. ControlWidgetBase::ControlWidgetBase( QWidget* parent, const QString &skinPath,  
  2.                         const QString &type, const char* name ) :  
  3.     QWidget(parent, name), buttonCount(0), slider(Qt::Horizontal, this),  
  4.     time(this), sliderBeingMoved(false), volumeTimeout(this), drawVolume(false)  
  5. {  
  6.     setCaption( tr("Media Player") );  
  7.      // 添加下面这一行  
  8.     closeBtn = new QPushButton( tr("close"), this);  

2



  1.    connect( &slider,           SIGNAL( sliderPressed() ),      this, SLOT( sliderPressed() ) );  
  2.    connect( &slider,           SIGNAL( sliderReleased() ),     this, SLOT( sliderReleased() ) );  
  3. //添加下面这行  
  4.    connect( closeBtn,          SIGNAL( pressed() ),            this, SLOT( close() ) );  

3



  1. imgButtonMask.fill( 0 );  
  2. //  此行下面修改如下  
  3. int closeBtnW = 48;  
  4. int y1 = h - timeHeight - 2 * border;  
  5. int x2 = w - timeWidth - border - cornerWidgetWidth - closeBtnW - border;  
  6. QRect sliderGeometry( border, y1, x2 - 2*border, timeHeight );  
  7. QRect timeGeometry( x2, y1, timeWidth, timeHeight );  
  8. QRect closeBtnGeometry( x2 + timeWidth + border, y1, closeBtnW, timeHeight);  
  9. getRect(cfg, skinType+"_slider", sliderGeometry, w, h);  
  10. getRect(cfg, skinType+"_time", timeGeometry, w, h);  
  11.   
  12. slider.setGeometry(sliderGeometry);  
  13. time.setGeometry(timeGeometry);  
  14. closeBtn->setGeometry(closeBtnGeometry);  

然后先编译libmediaplayer.so


再分别编译musi 与videos, 如果不重新编译运行会出现段错误.

就可以了.


例3:   给photoEdit的sider_show窗口添加 确定 与取消两个按钮

qtopia/src/applications/photoedit/slideshow/slideshowdialog.h

包含头

#include


  1. private:  
  2.     QLabel *slide_length_label;  
  3.     QSlider *slide_length_slider;  
  4.     QCheckBox *display_name_check, *loop_through_check;  
  5. //添加下面这行  
  6.     QPushButton *ok_button, *cancel_button;  

qtopia/src/applications/photoedit/slideshow/slideshowdialog.cpp



  1. // Construct loop through label and check box  
  2. loop_through_check = new QCheckBox( tr( "Loop through" ), this );  
  3. vbox->addWidget( loop_through_check );  
  4. nbsp;  
  1. // 加上下面这段  
  2. // Construct ok cancel buttons JYX_MODI add  
  3. QHBoxLayout *hbox = new QHBoxLayout;  
  4. ok_button = new QPushButton( tr( "Ok" ), this );  
  5. cancel_button = new QPushButton( tr( "Cancel" ), this );  
  6. connect( ok_button, SIGNAL( pressed() ), this, SLOT( accept() ) );  
  7. connect( cancel_button, SIGNAL( pressed() ), this, SLOT( reject() ) );  
  8. hbox->addWidget( ok_button );  
  9. hbox->addWidget( cancel_button );  
  10. vbox->addLayout( hbox );  
  11. // JYX_MODI add end  
重新编译photoEdit便可.
阅读(1474) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~