QT怎么制作出翻页效果

monicangl 2011-08-23 05:35:14
想做出那种很炫的效果,点击一个新的页面时,刷的展开,或者旧的页面刷的翻过去隐藏掉。

各位兄弟姐妹有没有什么idea,谢谢啦。。。
...全文
1275 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
Qyee16 2014-03-06
  • 打赏
  • 举报
回复
引用 1 楼 yiyaaixuexi 的回复:


void folding::paintEvent(QPaintEvent *event)
{

    QPainter painter(this);

    painter.fillRect(rect(), Qt::black);
    painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
    painter.setRenderHint(QPainter::Antialiasing, true);

    painter.drawPixmap(0, 0, m_pixmap);

    int index = m_animator.currentFrame();

    if(index>=99)
        return;


    if(direct==Left)
    {
        QPoint mouse_pos=QPoint(800-index*8,600-60*index/10);

        QPainterPath path1;
        QPainterPath path2;
        QPainterPath path3;

        /* Draw region 1 */
        painter.save ();
        path1.moveTo(0,600);
        path1.lineTo(mouse_pos.x(), 600);
        path1.lineTo(800, mouse_pos.y());
        path1.lineTo(800,0);
        path1.lineTo(0,0);
        path1.closeSubpath();
        painter.setClipPath (path1);
        painter.drawPixmap (0,0, m_lastPixmap);
        painter.restore();

        /*Draw region 2*/
        painter.save();
        path2.moveTo(mouse_pos.x(), 600);
        path2.lineTo(800, mouse_pos.y());
        path2.lineTo(800, 600);
        path2.closeSubpath ();
        painter.setClipPath (path2);
        painter.drawPixmap (0,0,m_pixmap);
        painter.restore();

        /* Draw region 3 */
        path3.moveTo(mouse_pos.x(), 600);
        path3.cubicTo(mouse_pos.x(), 600, mouse_pos.x()+9*index/5,(mouse_pos.y()+600)/2, mouse_pos.x(), mouse_pos.y());
        path3.cubicTo(mouse_pos.x(), mouse_pos.y(), (mouse_pos.x()+800)/2, mouse_pos.y()+7*index/5, 800, mouse_pos.y());
        path3.closeSubpath();
//  painter.setBrush(QBrush(QColor(0xF0,0xF8,0xFF)));
// painter.setOpacity(0.9);
        painter.setBrush(QBrush(QImage(":/images/image/0.png")));
        painter.drawPath(path3);
    }
    else if(direct==Right)
    {
        QPoint mouse_pos=QPoint(index*8,600-42*index/10);

        QPainterPath path1;
        QPainterPath path2;
        QPainterPath path3;

        /* Draw region 1 */
        painter.save ();
        path1.moveTo(800,600);
        path1.lineTo(mouse_pos.x(), 600);
        path1.lineTo(0, mouse_pos.y());
        path1.lineTo(0,0);
        path1.lineTo(800,0);
        path1.closeSubpath();
        painter.setClipPath (path1);
        painter.drawPixmap (0,0, m_lastPixmap);
        painter.restore();

        /*Draw region 2*/
        painter.save();
        path2.moveTo(mouse_pos.x(), 600);
        path2.lineTo(0, mouse_pos.y());
        path2.lineTo(0, 600);
        path2.closeSubpath ();
        painter.setClipPath (path2);
        painter.drawPixmap (0,0,m_pixmap);
        painter.restore();

        /* Draw region 3 */
        path3.moveTo(mouse_pos.x(), 600);
        path3.cubicTo(mouse_pos.x(), 600, mouse_pos.x()-9*index/5,(mouse_pos.y()+600)/2, mouse_pos.x(), mouse_pos.y());
        path3.cubicTo(mouse_pos.x(), mouse_pos.y(), (mouse_pos.x())/2, mouse_pos.y()+7*index/5, 0, mouse_pos.y());
        path3.closeSubpath();
// painter.setBrush(QBrush(QColor(0xF0,0xF8,0xFF)));
//        painter.setOpacity(0.9);
        painter.setBrush(QBrush(QImage(":/images/image/0.png")));
        painter.drawPath(path3);
    }
}
http://download.csdn.net/download/strong46066999/3082155 和这个代码一样。。。。
chen_jiancong 2011-08-25
  • 打赏
  • 举报
回复
如果写下注释该多好啊,有点看不明白
blueliuyun 2011-08-25
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 yiyaaixuexi 的回复:]
C/C++ code


void folding::paintEvent(QPaintEvent *event)
{

QPainter painter(this);

painter.fillRect(rect(), Qt::black);
painter.setRenderHint(QPainter::SmoothPixmapTransform, t……
[/Quote]
哇……更换头像了啊?
zhu_xz 2011-08-25
  • 打赏
  • 举报
回复
http://www.substanceofcode.com/2011/03/14/flipboard-page-flip-with-qt-qml/
LJSKR 2011-08-24
  • 打赏
  • 举报
回复
现在还看不明白,先收藏了……
钱国正 2011-08-24
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 yiyaaixuexi 的回复:]

C/C++ code


void folding::paintEvent(QPaintEvent *event)
{

QPainter painter(this);

painter.fillRect(rect(), Qt::black);
painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
……
[/Quote]虽然说这个精华,我还是不太懂撒
changing_better 2011-08-24
  • 打赏
  • 举报
回复
最好带注释,嘿嘿
top_dada 2011-08-23
  • 打赏
  • 举报
回复
果断收藏。。。
冰镇宝贝321 2011-08-23
  • 打赏
  • 举报
回复
念茜 2011-08-23
  • 打赏
  • 举报
回复


void folding::paintEvent(QPaintEvent *event)
{

QPainter painter(this);

painter.fillRect(rect(), Qt::black);
painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
painter.setRenderHint(QPainter::Antialiasing, true);

painter.drawPixmap(0, 0, m_pixmap);

int index = m_animator.currentFrame();

if(index>=99)
return;


if(direct==Left)
{
QPoint mouse_pos=QPoint(800-index*8,600-60*index/10);

QPainterPath path1;
QPainterPath path2;
QPainterPath path3;

/* Draw region 1 */
painter.save ();
path1.moveTo(0,600);
path1.lineTo(mouse_pos.x(), 600);
path1.lineTo(800, mouse_pos.y());
path1.lineTo(800,0);
path1.lineTo(0,0);
path1.closeSubpath();
painter.setClipPath (path1);
painter.drawPixmap (0,0, m_lastPixmap);
painter.restore();

/*Draw region 2*/
painter.save();
path2.moveTo(mouse_pos.x(), 600);
path2.lineTo(800, mouse_pos.y());
path2.lineTo(800, 600);
path2.closeSubpath ();
painter.setClipPath (path2);
painter.drawPixmap (0,0,m_pixmap);
painter.restore();

/* Draw region 3 */
path3.moveTo(mouse_pos.x(), 600);
path3.cubicTo(mouse_pos.x(), 600, mouse_pos.x()+9*index/5,(mouse_pos.y()+600)/2, mouse_pos.x(), mouse_pos.y());
path3.cubicTo(mouse_pos.x(), mouse_pos.y(), (mouse_pos.x()+800)/2, mouse_pos.y()+7*index/5, 800, mouse_pos.y());
path3.closeSubpath();
// painter.setBrush(QBrush(QColor(0xF0,0xF8,0xFF)));
// painter.setOpacity(0.9);
painter.setBrush(QBrush(QImage(":/images/image/0.png")));
painter.drawPath(path3);
}
else if(direct==Right)
{
QPoint mouse_pos=QPoint(index*8,600-42*index/10);

QPainterPath path1;
QPainterPath path2;
QPainterPath path3;

/* Draw region 1 */
painter.save ();
path1.moveTo(800,600);
path1.lineTo(mouse_pos.x(), 600);
path1.lineTo(0, mouse_pos.y());
path1.lineTo(0,0);
path1.lineTo(800,0);
path1.closeSubpath();
painter.setClipPath (path1);
painter.drawPixmap (0,0, m_lastPixmap);
painter.restore();

/*Draw region 2*/
painter.save();
path2.moveTo(mouse_pos.x(), 600);
path2.lineTo(0, mouse_pos.y());
path2.lineTo(0, 600);
path2.closeSubpath ();
painter.setClipPath (path2);
painter.drawPixmap (0,0,m_pixmap);
painter.restore();

/* Draw region 3 */
path3.moveTo(mouse_pos.x(), 600);
path3.cubicTo(mouse_pos.x(), 600, mouse_pos.x()-9*index/5,(mouse_pos.y()+600)/2, mouse_pos.x(), mouse_pos.y());
path3.cubicTo(mouse_pos.x(), mouse_pos.y(), (mouse_pos.x())/2, mouse_pos.y()+7*index/5, 0, mouse_pos.y());
path3.closeSubpath();
// painter.setBrush(QBrush(QColor(0xF0,0xF8,0xFF)));
// painter.setOpacity(0.9);
painter.setBrush(QBrush(QImage(":/images/image/0.png")));
painter.drawPath(path3);
}
}
qt 滑屏翻页效果C++程序 #ifndef PICTUREFLOW_H #define PICTUREFLOW_H #include class PictureFlowPrivate; /*! Class PictureFlow implements an image show widget with animation effect like Apple's CoverFlow (in iTunes and iPod). Images are arranged in form of slides, one main slide is shown at the center with few slides on the left and right sides of the center slide. When the next or previous slide is brought to the front, the whole slides flow to the right or the right with smooth animation effect; until the new slide is finally placed at the center. */ class PictureFlow : public QWidget { Q_OBJECT Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor) Q_PROPERTY(QSize slideSize READ slideSize WRITE setSlideSize) Q_PROPERTY(int slideCount READ slideCount) Q_PROPERTY(int centerIndex READ centerIndex WRITE setCenterIndex) public: enum ReflectionEffect { NoReflection, PlainReflection, BlurredReflection }; /*! Creates a new PictureFlow widget. */ PictureFlow(QWidget* parent = 0); /*! Destroys the widget. */ ~PictureFlow(); /*! Returns the background color. */ QColor backgroundColor() const; /*! Sets the background color. By default it is black. */ void setBackgroundColor(const QColor& c); /*! Returns the dimension of each slide (in pixels). */ QSize slideSize() const; /*! Sets the dimension of each slide (in pixels). */ void setSlideSize(QSize size); /*! Returns the total number of slides. */ int slideCount() const; /*! Returns QImage of specified slide. */ QImage slide(int index) const; /*! Returns the index of slide currently shown in the middle of the viewport. */ int centerIndex() const; /*! Returns the effect applied to the reflection. */ ReflectionEffect reflectionEffect() const; /*! Sets the effect applied to the reflection. The default is PlainReflection. */ void setReflectionEffect(ReflectionEffect effect); public slots: /*! Adds a new slide. */ void addSlide(const QImage& image); /*! Adds a new slide. */ void addSlide(const QPixmap& pixmap); /*! Sets an image for specified slide. If the slide already exists, it will be replaced. */ void setSlide(int index, const QImage& image); /*! Sets a pixmap for specified slide. If the slide already exists, it will be replaced. */ void setSlide(int index, const QPixmap& pixmap); /*! Sets slide to be shown in the middle of the viewport. No animation effect will be produced, unlike using showSlide. */ void setCenterIndex(int index); /*! Clears all slides. */ void clear(); /*! Shows previous slide using animation effect. */ void showPrevious(); /*! Shows next slide using animation effect. */ void showNext(); /*! Go to specified slide using animation effect. */ void showSlide(int index); /*! Rerender the widget. Normally this function will be automatically invoked whenever necessary, e.g. during the transition animation. */ void render(); /*! Schedules a rendering update. Unlike render(), this function does not cause immediate rendering. */ void triggerRender(); signals: void centerIndexChanged(int index); protected: void paintEvent(QPaintEvent *event); void keyPressEvent(QKeyEvent* event); void mousePressEvent(QMouseEvent* event); void resizeEvent(QResizeEvent* event); private slots: void updateAnimation(); private: PictureFlowPrivate* d; }; #endif // PICTUREFLOW_H

16,816

社区成员

发帖
与我相关
我的任务
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
  • Qt
  • 亭台六七座
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧