what I want: show image at the central of the QMainwindow(centralWidget)
but after resizing, the image is still at the previous position

my code is like this:

Qt Code:
  1. SLD::SLD(QWidget *parent, Qt::WFlags flags)
  2. : QMainWindow(parent, flags)
  3. {
  4. ui.setupUi(this);
  5. }
  6.  
  7. void SLD::showCB(int x, int y, int w, int h)
  8. {
  9. label=new QLabel(ui.centralWidget);
  10. label->setGeometry(x,y,w,h);
  11. label->setPixmap(QPixmap("Resources/CB.bmp"));
  12. }
  13.  
  14. void SLD::resizeEvent(QResizeEvent * /* event */)
  15. {
  16. mWidth = width();
  17. showCB((mWidth-50)/2,0,100,50);
  18. }
To copy to clipboard, switch view to plain text mode 
please help me.