├── Readme.txt ├── RotatingStackedWidget.cpp ├── RotatingStackedWidget.h └── example ├── example.pro ├── main.cpp ├── mainwindow.cpp ├── mainwindow.h ├── mainwindow.ui ├── pageone.cpp ├── pageone.h ├── pageone.ui ├── pagetwo.cpp ├── pagetwo.h └── pagetwo.ui /Readme.txt: -------------------------------------------------------------------------------- 1 | //usage 2 | 3 | RotatingStackedWidget* rotWidget = new RotatingStackedWidget; 4 | 5 | 6 | rotWidget->addWidget(widget1); 7 | rotWidget->addWidget(widget2); 8 | rotWidget->setCurrentWidget(widget1); 9 | 10 | rotWidget->rotate(0); -------------------------------------------------------------------------------- /RotatingStackedWidget.cpp: -------------------------------------------------------------------------------- 1 | #include "RotatingStackedWidget.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | 11 | RotatingStackedWidget::RotatingStackedWidget(QWidget *parent) : 12 | QStackedWidget(parent) 13 | { 14 | iRotateVal=0; 15 | isAnimating=false; 16 | } 17 | void RotatingStackedWidget::paintEvent(QPaintEvent * event) 18 | { 19 | if(isAnimating) 20 | { 21 | if(iRotateVal > 90) 22 | { 23 | QPixmap pixmap(widget(nextIndex)->size()); 24 | widget(nextIndex)->render(&pixmap); 25 | QPainter painter(this); 26 | 27 | QTransform transform; 28 | transform.translate(width()/2, 0); 29 | transform.rotate(iRotateVal+180,Qt::YAxis); 30 | painter.setTransform(transform); 31 | painter.drawPixmap(-1*width()/2,0,pixmap); 32 | } 33 | else 34 | { 35 | QPixmap pixmap(currentWidget()->size()); 36 | currentWidget()->render(&pixmap); 37 | QPainter painter(this); 38 | 39 | QTransform transform; 40 | transform.translate(width()/2, 0); 41 | transform.rotate(iRotateVal,Qt::YAxis); 42 | painter.setTransform(transform); 43 | painter.drawPixmap(-1*width()/2,0,pixmap); 44 | } 45 | } 46 | else 47 | { 48 | QWidget::paintEvent(event); 49 | } 50 | } 51 | 52 | void RotatingStackedWidget::rotate(int index) 53 | { 54 | if(isAnimating) 55 | return; 56 | 57 | nextIndex = index; 58 | 59 | int offsetx=frameRect().width(); 60 | int offsety=frameRect().height(); 61 | 62 | 63 | widget(index)->setGeometry ( 0, 0, offsetx, offsety ); 64 | 65 | QPropertyAnimation *animnow = new QPropertyAnimation(this,"rotateVal"); 66 | 67 | animnow->setDuration(500); 68 | animnow->setEasingCurve(QEasingCurve::Linear); 69 | animnow->setStartValue(0); 70 | animnow->setEndValue(180); 71 | connect(animnow,SIGNAL(valueChanged(QVariant)),this,SLOT(valChanged(QVariant))); 72 | connect(animnow,SIGNAL(finished()),this,SLOT(animDone())); 73 | 74 | currentWidget()->hide(); 75 | 76 | isAnimating = true; 77 | animnow->start();; 78 | } 79 | 80 | 81 | float RotatingStackedWidget::rotateVal() 82 | { 83 | return iRotateVal; 84 | } 85 | void RotatingStackedWidget::setRotateVal(float fl) 86 | { 87 | iRotateVal = fl; 88 | } 89 | 90 | 91 | void RotatingStackedWidget::valChanged(QVariant) 92 | { 93 | repaint(); 94 | } 95 | 96 | void RotatingStackedWidget::animDone() 97 | { 98 | iRotateVal=0; 99 | isAnimating=false; 100 | widget(nextIndex)->show(); 101 | widget(nextIndex)->raise();; 102 | setCurrentWidget(widget(nextIndex)); 103 | repaint(); 104 | 105 | } 106 | -------------------------------------------------------------------------------- /RotatingStackedWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET1_H 2 | #define WIDGET1_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | class RotatingStackedWidget : public QStackedWidget 9 | { 10 | Q_OBJECT 11 | 12 | Q_PROPERTY( float rotateVal READ rotateVal WRITE setRotateVal); 13 | public: 14 | explicit RotatingStackedWidget(QWidget *parent = 0); 15 | void paintEvent(QPaintEvent *); 16 | void rotate(int); 17 | 18 | float rotateVal(); 19 | void setRotateVal(float); 20 | 21 | signals: 22 | 23 | private slots: 24 | void valChanged(QVariant); 25 | void animDone(); 26 | private: 27 | float iRotateVal; 28 | 29 | bool isAnimating; 30 | int nextIndex; 31 | }; 32 | 33 | #endif // WIDGET1_H 34 | -------------------------------------------------------------------------------- /example/example.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2012-12-06T11:58:43 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui webkit 8 | 9 | TARGET = example 10 | TEMPLATE = app 11 | 12 | 13 | SOURCES += main.cpp\ 14 | mainwindow.cpp \ 15 | RotatingStackedWidget.cpp \ 16 | pageone.cpp \ 17 | pagetwo.cpp 18 | 19 | HEADERS += mainwindow.h \ 20 | RotatingStackedWidget.h \ 21 | pageone.h \ 22 | pagetwo.h 23 | 24 | FORMS += mainwindow.ui \ 25 | pageone.ui \ 26 | pagetwo.ui 27 | 28 | INCLUDEPATH += ../ 29 | DEPENDPATH += ../ 30 | -------------------------------------------------------------------------------- /example/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "mainwindow.h" 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | MainWindow w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /example/mainwindow.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include "ui_mainwindow.h" 3 | 4 | #include 5 | #include 6 | 7 | #include "RotatingStackedWidget.h" 8 | #include "pageone.h" 9 | #include "pagetwo.h" 10 | 11 | MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) 12 | { 13 | ui->setupUi(this); 14 | 15 | stack = new RotatingStackedWidget(this); 16 | ui->mainLayout->addWidget(stack); 17 | 18 | PageOne * page1 = new PageOne; 19 | PageTwo * page2 = new PageTwo; 20 | 21 | stack->addWidget(page1); 22 | stack->addWidget(page2); 23 | 24 | connect(ui->buttonFw,SIGNAL(clicked()),SLOT(stepForward())); 25 | connect(ui->buttonBw,SIGNAL(clicked()),SLOT(stepBackward())); 26 | } 27 | 28 | MainWindow::~MainWindow() 29 | { 30 | delete ui; 31 | } 32 | 33 | void MainWindow::stepForward() 34 | { 35 | stack->rotate(1); 36 | } 37 | 38 | void MainWindow::stepBackward() 39 | { 40 | stack->rotate(0); 41 | } 42 | -------------------------------------------------------------------------------- /example/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class MainWindow; 8 | } 9 | 10 | class RotatingStackedWidget; 11 | 12 | class MainWindow : public QMainWindow 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit MainWindow(QWidget *parent = 0); 18 | ~MainWindow(); 19 | 20 | private slots: 21 | void stepForward(); 22 | void stepBackward(); 23 | 24 | private: 25 | Ui::MainWindow *ui; 26 | RotatingStackedWidget * stack; 27 | }; 28 | 29 | #endif // MAINWINDOW_H 30 | -------------------------------------------------------------------------------- /example/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 21 | Rotate - 22 | 23 | 24 | 25 | 26 | 27 | 28 | Qt::Horizontal 29 | 30 | 31 | 32 | 225 33 | 20 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | Rotate + 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 0 59 | 0 60 | 400 61 | 21 62 | 63 | 64 | 65 | 66 | 67 | TopToolBarArea 68 | 69 | 70 | false 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /example/pageone.cpp: -------------------------------------------------------------------------------- 1 | #include "pageone.h" 2 | #include "ui_pageone.h" 3 | 4 | PageOne::PageOne(QWidget *parent) : 5 | QWidget(parent), 6 | ui(new Ui::PageOne) 7 | { 8 | ui->setupUi(this); 9 | } 10 | 11 | PageOne::~PageOne() 12 | { 13 | delete ui; 14 | } 15 | -------------------------------------------------------------------------------- /example/pageone.h: -------------------------------------------------------------------------------- 1 | #ifndef PAGEONE_H 2 | #define PAGEONE_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class PageOne; 8 | } 9 | 10 | class PageOne : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit PageOne(QWidget *parent = 0); 16 | ~PageOne(); 17 | 18 | private: 19 | Ui::PageOne *ui; 20 | }; 21 | 22 | #endif // PAGEONE_H 23 | -------------------------------------------------------------------------------- /example/pageone.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | PageOne 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | Qt::Vertical 24 | 25 | 26 | 27 | 28 | 29 | 30 | Qt::Horizontal 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | horizontalSlider 40 | sliderMoved(int) 41 | dial 42 | setValue(int) 43 | 44 | 45 | 29 46 | 282 47 | 48 | 49 | 80 50 | 91 51 | 52 | 53 | 54 | 55 | verticalSlider 56 | sliderMoved(int) 57 | dial 58 | setValue(int) 59 | 60 | 61 | 381 62 | 107 63 | 64 | 65 | 142 66 | 93 67 | 68 | 69 | 70 | 71 | dial 72 | sliderMoved(int) 73 | horizontalSlider 74 | setValue(int) 75 | 76 | 77 | 125 78 | 121 79 | 80 | 81 | 135 82 | 284 83 | 84 | 85 | 86 | 87 | dial 88 | sliderMoved(int) 89 | verticalSlider 90 | setValue(int) 91 | 92 | 93 | 126 94 | 116 95 | 96 | 97 | 378 98 | 164 99 | 100 | 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /example/pagetwo.cpp: -------------------------------------------------------------------------------- 1 | #include "pagetwo.h" 2 | #include "ui_pagetwo.h" 3 | 4 | PageTwo::PageTwo(QWidget *parent) : 5 | QWidget(parent), 6 | ui(new Ui::PageTwo) 7 | { 8 | ui->setupUi(this); 9 | } 10 | 11 | PageTwo::~PageTwo() 12 | { 13 | delete ui; 14 | } 15 | -------------------------------------------------------------------------------- /example/pagetwo.h: -------------------------------------------------------------------------------- 1 | #ifndef PAGETWO_H 2 | #define PAGETWO_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class PageTwo; 8 | } 9 | 10 | class PageTwo : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit PageTwo(QWidget *parent = 0); 16 | ~PageTwo(); 17 | 18 | private: 19 | Ui::PageTwo *ui; 20 | }; 21 | 22 | #endif // PAGETWO_H 23 | -------------------------------------------------------------------------------- /example/pagetwo.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | PageTwo 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | 21 | http://www.google.md/ 22 | 23 | 24 | 25 | QPainter::Antialiasing|QPainter::HighQualityAntialiasing|QPainter::NonCosmeticDefaultPen|QPainter::SmoothPixmapTransform|QPainter::TextAntialiasing 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | QWebView 34 | QWidget 35 |
QtWebKit/QWebView
36 |
37 |
38 | 39 | 40 |
41 | --------------------------------------------------------------------------------