QT怎么制作出翻页效果

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

各位兄弟姐妹有没有什么idea,谢谢啦。。。
...全文
1231 10 打赏 收藏 转发到动态 举报
写回复
用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);
}
}

16,240

社区成员

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

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