武松娱乐_武松国际_武松国际娱乐  |  最近更新  |  TAG  | 
武松娱乐_武松国际_武松国际娱乐
当前位置:首页 > 武松娱乐_武松国际_武松国际娱乐

武松娱乐_武松国际_武松国际娱乐

来源:互联网 时间:2017-07-21 阅读: 手机版
篇一:武松娱乐_武松国际_武松国际娱乐1. 子窗体或控件,重写paintEvent事件,画边框、背景、文字、图片效果比较好。用paintEvent 事件画边框,用QPalette设置背景。http://blog.csdn.net/imxiangzi/article/details/50154951/// 画边框http://blog.csdn.net/imxiangzi/article/details/50154951/  QPainter painter(this);http://blog.csdn.net/imxiangzi/article/details/50154951/  painter.setRenderHint(QPainter::Antialiasing, true);http://blog.csdn.net/imxiangzi/article/details/50154951/  painter.setPen(QPen(QColor(225,70,56), 2));http://blog.csdn.net/imxiangzi/article/details/50154951///  painter.setBrush(QColor(16,62,81));  // 也可设置背景,有时效果不好http://blog.csdn.net/imxiangzi/article/details/50154951/  painter.drawRoundedRect(rect(), 5.0, 5.0);http://blog.csdn.net/imxiangzi/article/details/50154951/// 设置背景http://blog.csdn.net/imxiangzi/article/details/50154951/  QPalette pal = palette();http://blog.csdn.net/imxiangzi/article/details/50154951/  pal.setBrush(QPalette::Window, QColor(16,62,81));http://blog.csdn.net/imxiangzi/article/details/50154951/  setPalette(pal);http://blog.csdn.net/imxiangzi/article/details/50154951/  setAutoFillBackground(true); 继承QDialog,想让对话框以模态运行,使用exec(),继承时使用setWindowFlags()后则达不到模态的效果。不知道原因。 QStringList 输出http://blog.csdn.net/imxiangzi/article/details/50154951/QStringList m_strLang English http://blog.csdn.net/imxiangzi/article/details/50154951/  Chinese http://blog.csdn.net/imxiangzi/article/details/50154951/qDebug( set language: %s , m_strLang.at(0).toLocal8Bit().constData()); QStringList 使用注意http://blog.csdn.net/imxiangzi/article/details/50154951/  QStringList strDateformatList;http://blog.csdn.net/imxiangzi/article/details/50154951/  strDateformatListhttp://blog.csdn.net/imxiangzi/article/details/50154951/  m_strMonth - m_strDay - m_strYearhttp://blog.csdn.net/imxiangzi/article/details/50154951/  m_strDay - m_strMonth - m_strYearhttp://blog.csdn.net/imxiangzi/article/details/50154951/  m_strYear - m_strMonth - m_strDayhttp://blog.csdn.net/imxiangzi/article/details/50154951/  ;http://blog.csdn.net/imxiangzi/article/details/50154951/如果strDateformatList 在生命周期内多次调用,则会多次插入字符串,使得字符串重复,这不是我们想要的。那就定义为局部变量,每次会重新赋 ,达到更新的目的。需要动态重新的页面可以在showEvent函数中重新。 用paintEvent或用调色板为QWidget填充背景时,需要加上setAutoFillBackground(true);语句,否则没效果。 想使弹出的窗口为圆角,用paintEvent画圆角矩形,但四个直角仍然存在,不美观。可以把背景设为透明,用paintEvent画出想要的背景,因为四个角没有画上背景,是透明的,所以看不见。http://blog.csdn.net/imxiangzi/article/details/50154951/  // 设置背景为透明 (构造函数中)http://blog.csdn.net/imxiangzi/article/details/50154951/  QPalette pal = palette();http://blog.csdn.net/imxiangzi/article/details/50154951/  pal.setBrush(QPalette::Window, QColor(255, 255, 255, 0));http://blog.csdn.net/imxiangzi/article/details/50154951/  setPalette(pal);http://blog.csdn.net/imxiangzi/article/details/50154951/  setAutoFillBackground(true);http://blog.csdn.net/imxiangzi/article/details/50154951/  // 画背景和边框 (paintEvent函数中)http://blog.csdn.net/imxiangzi/article/details/50154951/  QPainter painter(this);http://blog.csdn.net/imxiangzi/article/details/50154951/  painter.setRenderHint(QPainter::Antialiasing, true);http://blog.csdn.net/imxiangzi/article/details/50154951/  painter.setPen(QPen(QColor(225,70,56), 2));http://blog.csdn.net/imxiangzi/article/details/50154951/  painter.setBrush(QColor(16,62,81));http://blog.csdn.net/imxiangzi/article/details/50154951/  painter.drawRoundedRect(rect(), 5.0, 5.0); Qt::Key_Enter、Qt::Key_Returehttp://blog.csdn.net/imxiangzi/article/details/50154951/Qt::Key_Enter对应小键盘的Enter键http://blog.csdn.net/imxiangzi/article/details/50154951/Qt::Key_Return对应大键盘的Enter键 事件过滤。窗口部件的事件到达目的地之前提前获取并处理相关事件,实现个性化的处理。http://blog.csdn.net/imxiangzi/article/details/50154951/我在QLabel对象中放入两个QPushButton对象和两个QLabel对象,QPushButton实现 的调节,其中一个QLabel对象用于显示 ,一个QLabel对象用于显示标题。类 SpinBox。在多个SpinBox上点击实现焦点切换,当鼠标点到QPushButton上时,QPushButton处理了mousePressEvent事件,所以无法实现焦点切换。为两个QPushButton对象安装事件过滤器,然后在其父部件中处理eventFilter函数http://blog.csdn.net/imxiangzi/article/details/50154951/m_btnLeft- installEventFilter(this);http://blog.csdn.net/imxiangzi/article/details/50154951/m_btnRight- installEventFilter(this);http://blog.csdn.net/imxiangzi/article/details/50154951///安装事件过滤器后,传给m_btnLeft、m_btnRight的事件会首先发送给eventFilter函数http://blog.csdn.net/imxiangzi/article/details/50154951/bool ESpinBoxItem::eventFilter(QObject*obj,QEvent*ev)http://blog.csdn.net/imxiangzi/article/details/50154951/{http://blog.csdn.net/imxiangzi/article/details/50154951/if(obj == m_btnLeft || obj == m_btnRight)http://blog.csdn.net/imxiangzi/article/details/50154951/{http://blog.csdn.net/imxiangzi/article/details/50154951/if(ev- type() == QEvent::MouseButtonPress)http://blog.csdn.net/imxiangzi/article/details/50154951/{http://blog.csdn.net/imxiangzi/article/details/50154951/emit sign_spinBoxPressed(m_nItem);http://blog.csdn.net/imxiangzi/article/details/50154951/return true; // 不传给目标对象处理http://blog.csdn.net/imxiangzi/article/details/50154951/}http://blog.csdn.net/imxiangzi/article/details/50154951/}http://blog.csdn.net/imxiangzi/article/details/50154951/return false; // 不处理的事件则传给目标对象处理http://blog.csdn.net/imxiangzi/article/details/50154951/}http://blog.csdn.net/imxiangzi/article/details/50154951/10. 拍照动画http://blog.csdn.net/imxiangzi/article/details/50154951/使用QTimeLine和QGraphicsPixmapItem对象,当时间线帧改变时,设置QGraphicsPixmapItem的位置,实现动画效果。http://blog.csdn.net/imxiangzi/article/details/50154951/// 在QGraphicsView构造函数中http://blog.csdn.net/imxiangzi/article/details/50154951/// take photo animationhttp://blog.csdn.net/imxiangzi/article/details/50154951/  m_timerAnimation = new QTimeLine(900);http://blog.csdn.net/imxiangzi/article/details/50154951/  m_timerAnimation- setCurveShape(QTimeLine::LinearCurve);http://blog.csdn.net/imxiangzi/article/details/50154951/  m_timerAnimation- setFrameRange(0, 240);http://blog.csdn.net/imxiangzi/article/details/50154951/  m_pixmapUpAnimation = QPixmap( :/images/animation.png http://blog.csdn.net/imxiangzi/article/details/50154951/  m_pixmapDownAnimation = QPixmap( :/images/animation.png http://blog.csdn.net/imxiangzi/article/details/50154951/  m_upPixmapItem = new QGraphicsPixmapItem;http://blog.csdn.net/imxiangzi/article/details/50154951/  m_downPixmapItem = new QGraphicsPixmapItem;http://blog.csdn.net/imxiangzi/article/details/50154951/  m_upPixmapItem- setZValue(4);http://blog.csdn.net/imxiangzi/article/details/50154951/  m_downPixmapItem- setZValue(4);http://blog.csdn.net/imxiangzi/article/details/50154951/  m_upPixmapItem- setPos(0, 0);  // 左上角为原点http://blog.csdn.net/imxiangzi/article/details/50154951/  m_downPixmapItem- setPos(0, 240);http://blog.csdn.net/imxiangzi/article/details/50154951/  scene()- addItem(m_upPixmapItem);http://blog.csdn.net/imxiangzi/article/details/50154951/  scene()- addItem(m_downPixmapItem);http://blog.csdn.net/imxiangzi/article/details/50154951/  m_upPixmapItem- hide();http://blog.csdn.net/imxiangzi/article/details/50154951/  m_downPixmapItem- hide();http://blog.csdn.net/imxiangzi/article/details/50154951/  connect(m_timerAnimation, SIGNAL(frameChanged(int)), this, SLOT(slot_playAnimation(int)));http://blog.csdn.net/imxiangzi/article/details/50154951/// 槽函数http://blog.csdn.net/imxiangzi/article/details/50154951/void EGraphicsView::slot_playAnimation(int nFrame)http://blog.csdn.net/imxiangzi/article/details/50154951/{http://blog.csdn.net/imxiangzi/article/details/50154951/  m_upPixmapItem- show();http://blog.csdn.net/imxiangzi/article/details/50154951/  m_downPixmapItem- show();http://blog.csdn.net/imxiangzi/article/details/50154951/  qDebug( nFrame: %d , nFrame);http://blog.csdn.net/imxiangzi/article/details/50154951/  if(nFrame 120)http://blog.csdn.net/imxiangzi/article/details/50154951/  {http://blog.csdn.net/imxiangzi/article/details/50154951/  m_upPixmapItem- setPixmap(m_pixmapUpAnimation.scaled(320, nFrame));http://blog.csdn.net/imxiangzi/article/details/50154951/  m_downPixmapItem- setPixmap(m_pixmapDownAnimation.scaled(320, nFrame));http://blog.csdn.net/imxiangzi/article/details/50154951/  m_downPixmapItem- setPos(0, 240 - nFrame);http://blog.csdn.net/imxiangzi/article/details/50154951/  }http://blog.csdn.net/imxiangzi/article/details/50154951/  elsehttp://blog.csdn.net/imxiangzi/article/details/50154951/  {http://blog.csdn.net/imxiangzi/article/details/50154951/  m_upPixmapItem- setPixmap(m_pixmapUpAnimation.scaled(320, 240 - nFrame));http://blog.csdn.net/imxiangzi/article/details/50154951/  m_downPixmapItem- setPixmap(m_pixmapDownAnimation.scaled(320, 240 - nFrame));http://blog.csdn.net/imxiangzi/article/details/50154951/  m_downPixmapItem- setPos(0, nFrame);http://blog.csdn.net/imxiangzi/article/details/50154951/  }http://blog.csdn.net/imxiangzi/article/details/50154951/}http://blog.csdn.net/imxiangzi/article/details/50154951/11.在移动设备上使用渐变或使用渐变的图片时,会出现条纹状,达不到效果。在初始化QApplication对像前调用下面的语句则可以达到效果:http://blog.csdn.net/imxiangzi/article/details/50154951/QApplication::setColorSpec(QApplication::ManyColor); //the right choice for applications that use thousands of colorshttp://blog.csdn.net/imxiangzi/article/details/50154951/QApplication app(argc, argv,  QApplication::GuiServer );http://blog.csdn.net/imxiangzi/article/details/50154951/12.用setStyleSheet设置背景图片http://blog.csdn.net/imxiangzi/article/details/50154951/m_labelButton- setStyleSheet( background-image: url(:images/shutdown/slider.png); background-repeat: no-repeat; //注意,不加background-repeat: no-repeat可能会出现透视,很丑。QLabel对象可用setPixmap设置象素图。http://blog.csdn.net/imxiangzi/article/details/50154951/13.使对话框圆角http://blog.csdn.net/imxiangzi/article/details/50154951/  //构造函数中http://blog.csdn.net/imxiangzi/article/details/50154951/  setAutoFillBackground(true);http://blog.csdn.net/imxiangzi/article/details/50154951/  QPalette pal = palette();http://blog.csdn.net/imxiangzi/article/details/50154951/  pal.setColor(QPalette::Window, QColor(0, 0, 0, 0));http://blog.csdn.net/imxiangzi/article/details/50154951/  setPalette(pal);http://blog.csdn.net/imxiangzi/article/details/50154951/  //paintEvent函数中http://blog.csdn.net/imxiangzi/article/details/50154951/  QPainter painter(this);http://blog.csdn.net/imxiangzi/article/details/50154951/  painter.setRenderHint(QPainter::Antialiasing,true);http://blog.csdn.net/imxiangzi/article/details/50154951/  painter.setPen(QPen(Qt::red,2));http://blog.csdn.net/imxiangzi/article/details/50154951/  painter.setBrush(QColor(16,62,81));http://blog.csdn.net/imxiangzi/article/details/50154951/  painter.drawRoundedRect(rect(),5.0,5.0);http://blog.csdn.net/imxiangzi/article/details/50154951/// 圆角处有杂色,原因不祥http://blog.csdn.net/imxiangzi/article/details/50154951/14. 对某些默认事件的处理修改http://blog.csdn.net/imxiangzi/article/details/50154951/正常情况下,按下Tab键,被QWidget看成是去移动键盘焦点,但少数窗口部件需要自行解释。http://blog.csdn.net/imxiangzi/article/details/50154951/bool MyClass::event(QEvent *e)http://blog.csdn.net/imxiangzi/article/details/50154951/{http://blog.csdn.net/imxiangzi/article/details/50154951/  if(e- type() == QEvent::KeyPress)http://blog.csdn.net/imxiangzi/article/details/50154951/  {http://blog.csdn.net/imxiangzi/article/details/50154951/  QKeyEvent *ke = (QKeyEvent *)e;http://blog.csdn.net/imxiangzi/article/details/50154951/  if(ke- key() == Qt::Key_Tab)http://blog.csdn.net/imxiangzi/article/details/50154951/  {http://blog.csdn.net/imxiangzi/article/details/50154951/  //这里是特定的Tab处理http://blog.csdn.net/imxiangzi/article/details/50154951/  k- accept();http://blog.csdn.net/imxiangzi/article/details/50154951/  return TRUE;http://blog.csdn.net/imxiangzi/article/details/50154951/  }http://blog.csdn.net/imxiangzi/article/details/50154951/  }http://blog.csdn.net/imxiangzi/article/details/50154951/  else if(e- type()  = QEvent::User)http://blog.csdn.net/imxiangzi/article/details/50154951/  {http://blog.csdn.net/imxiangzi/article/details/50154951/  // 这里是自定义事件处理http://blog.csdn.net/imxiangzi/article/details/50154951/  return TRUE;http://blog.csdn.net/imxiangzi/article/details/50154951/  }http://blog.csdn.net/imxiangzi/article/details/50154951/  QWidget::event(e);http://blog.csdn.net/imxiangzi/article/details/50154951/}http://blog.csdn.net/imxiangzi/article/details/50154951/  15.QLabel继承QFrame,有QFrame的特性。如setFrameStyle(int)可设置QLabel的FrameStyle(框架类型)http://blog.csdn.net/imxiangzi/article/details/50154951/FrameStyle有两种:http://blog.csdn.net/imxiangzi/article/details/50154951/a.第一种是frameshape:http://blog.csdn.net/imxiangzi/article/details/50154951/有以下几种类型:http://blog.csdn.net/imxiangzi/article/details/50154951/Constanthttp://blog.csdn.net/imxiangzi/article/details/50154951/Valuehttp://blog.csdn.net/imxiangzi/article/details/50154951/Descriptionhttp://blog.csdn.net/imxiangzi/article/details/50154951/QFrame::NoFramehttp://blog.csdn.net/imxiangzi/article/details/50154951/0http://blog.csdn.net/imxiangzi/article/details/50154951/ draws nothinghttp://blog.csdn.net/imxiangzi/article/details/50154951/QFrame::Boxhttp://blog.csdn.net/imxiangzi/article/details/50154951/0x0001http://blog.csdn.net/imxiangzi/article/details/50154951/ draws a box around its contentshttp://blog.csdn.net/imxiangzi/article/details/50154951/QFrame::Panelhttp://blog.csdn.net/imxiangzi/article/details/50154951/0x0002http://blog.csdn.net/imxiangzi/article/details/50154951/ draws a panel to make the contents appear raised or sunkenhttp://blog.csdn.net/imxiangzi/article/details/50154951/QFrame::StyledPanelhttp://blog.csdn.net/imxiangzi/article/details/50154951/0x0006http://blog.csdn.net/imxiangzi/article/details/50154951/draws a rectangular panel with a look that depends on the current GUI style. It can be raised or sunken.http://blog.csdn.net/imxiangzi/article/details/50154951/QFrame::HLinehttp://blog.csdn.net/imxiangzi/article/details/50154951/0x0004http://blog.csdn.net/imxiangzi/article/details/50154951/ draws a horizontal line that frames nothing (useful as separator)http://blog.csdn.net/imxiangzi/article/details/50154951/QFrame::VLinehttp://blog.csdn.net/imxiangzi/article/details/50154951/0x0005http://blog.csdn.net/imxiangzi/article/details/50154951/ draws a vertical line that frames nothing (useful as separator)http://blog.csdn.net/imxiangzi/article/details/50154951/QFrame::WinPanelhttp://blog.csdn.net/imxiangzi/article/details/50154951/0x0003http://blog.csdn.net/imxiangzi/article/details/50154951/draws a rectangular panel that can be raised or sunken like those in Windows 95. Specifying this shape sets the line width to 2 pixels. WinPanel is provided for compatibility. For GUI style independence we recommend using StyledPanel instead.http://blog.csdn.net/imxiangzi/article/details/50154951/b.第二种是frameshadowhttp://blog.csdn.net/imxiangzi/article/details/50154951/有以下几种类型:http://blog.csdn.net/imxiangzi/article/details/50154951/Constanthttp://blog.csdn.net/imxiangzi/article/details/50154951/Valuehttp://blog.csdn.net/imxiangzi/article/details/50154951/Descriptionhttp://blog.csdn.net/imxiangzi/article/details/50154951/QFrame::Plainhttp://blog.csdn.net/imxiangzi/article/details/50154951/0x0010http://blog.csdn.net/imxiangzi/article/details/50154951/the frame and contents appear level with the surroundings; draws using the palettecolor (without any 3D effect)http://blog.csdn.net/imxiangzi/article/details/50154951/QFrame::Raisedhttp://blog.csdn.net/imxiangzi/article/details/50154951/0x0020http://blog.csdn.net/imxiangzi/article/details/50154951/the frame and contents appear raised; draws a 3D raised line using the light and dark colors of the current color grouphttp://blog.csdn.net/imxiangzi/article/details/50154951/QFrame::Sunkenhttp://blog.csdn.net/imxiangzi/article/details/50154951/0x0030http://blog.csdn.net/imxiangzi/article/details/50154951/the frame and contents appear sunken; draws a 3D sunken line using the light and dark colors of the current color grouphttp://blog.csdn.net/imxiangzi/article/details/50154951/组合 的效果图:http://blog.csdn.net/imxiangzi/article/details/50154951/  lineEdit =new QLineEdit; label- setBuddy(lineEdit);  caseCheckBox= new QCheckBox(tr("Match case")); backwardCheckBox = new QCheckBox(tr("Search backward"));  finon =new QPushButton(tr(" Find")); finon- setDefault(true); finon- setEnabled(false);  closeButton= new QPushButton(tr("Close")); connect(lineEdit, SIGNAL(textChanged(const QString )), this, SLOT(enableFinon(const QString ))); connect(finon, SIGNAL(clicked()), this, SLOT(findClicked())); connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));  //使用布局管理器布局控件  QHBoxLayout*topLeftLayout = new QHBoxLayout; topLeftLayout- addWidget(label); topLeftLayout- addWidget(lineEdit);  QVBoxLayout*leftLayout = new QVBoxLayout; leftLayout- addLayout(topLeftLayout); leftLayout- addWidget(caseCheckBox); leftLayout- addWidget(backwardCheckBox);  QVBoxLayout*rightLayout = new QVBoxLayout; rightLayout- addWidget(finon); rightLayout- addWidget(closeButton); rightLayout- addStretch();  QHBoxLayout*mainLayout = new QHBoxLayout; mainLayout- addLayout(leftLayout); mainLayout- addLayout(rightLayout);  //设置窗口的布局管理器 setLayout(mainLayout);  setWindowTitle(tr("Find")); setFixedHeight(sizeHint().height());}使用Qt Designer设计界面 采用Qt Designer,使得快速创建对话框成为可能。在QtDesigner环境中,所有的操作都采用可视化的操作,可拖放控件、关联信号与槽、设置特定控件的属性。使用QtDesigner设计界面的方法如下图所示: 

猜你喜欢

最新文章

热门文章

武松娱乐