I tried QGraphicsView & QGraphicsSCene, but I not working as I expected. I'm calling the widget to show after 3 seconds using a singleshot timer. But I see the widget is flashing and disappearing.
Below is the way how I implemented see how it comes out.
#include "ccentralwidget.h"
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QTimer>
CMainWidget
::CMainWidget(QWidget *parent
) :{
this->setStyleSheet("background-color: lightGray;");
this->setFixedSize(650, 450);
m_widget = new CMenuWidget();
QTimer::singleShot(3000,
this,
SLOT(showMenuWidget
()));
}
CMainWidget::~CMainWidget()
{
delete m_widget;
}
void CMainWidget::showMenuWidget()
{
scene.addWidget(m_widget);
scene.setSceneRect(0, 30, 60, 250);
view.show();
}
#include "ccentralwidget.h"
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QTimer>
CMainWidget::CMainWidget(QWidget *parent) :
QWidget(parent)
{
this->setStyleSheet("background-color: lightGray;");
this->setFixedSize(650, 450);
m_widget = new CMenuWidget();
QTimer::singleShot(3000, this, SLOT(showMenuWidget()));
}
CMainWidget::~CMainWidget()
{
delete m_widget;
}
void CMainWidget::showMenuWidget()
{
QGraphicsScene scene;
scene.addWidget(m_widget);
scene.setSceneRect(0, 30, 60, 250);
QGraphicsView view(&scene);
view.show();
}
To copy to clipboard, switch view to plain text mode
---------------------------------------------------------------------------------------------
And I tried it using QPropertyAnimation also, but it's giving some error/warning messages output.
I'm calling the below slot in singleshot timer the same way as shown in the above code.
void CCentralWidget::showMenuWidget()
{
QPropertyAnimation *animation = new QPropertyAnimation(m_widget, "MyMenu");
animation->setDuration(2000);
animation
->setStartValue
(QRect(0,
0,
100,
30));
animation
->setEndValue
(QRect(250,
250,
100,
30));
animation->start();
}
void CCentralWidget::showMenuWidget()
{
QPropertyAnimation *animation = new QPropertyAnimation(m_widget, "MyMenu");
animation->setDuration(2000);
animation->setStartValue(QRect(0, 0, 100, 30));
animation->setEndValue(QRect(250, 250, 100, 30));
animation->start();
}
To copy to clipboard, switch view to plain text mode
//Output Message:
QPropertyAnimation: you're trying to animate a non-existing property MyMenu of your QObject
//Output Message:
QPropertyAnimation: you're trying to animate a non-existing property MyMenu of your QObject
To copy to clipboard, switch view to plain text mode
I need to show/hide the widget the same way how the left app menu widget is shown/hidden on mouse move to the left area in Ubuntu unity and this kind of graphics can be seen a text editor called Scribes.
So for now I'm trying to achieve the same transition on singleshot timer, later I call it in movemove event.
Kindly help me. Thank you.
Bookmarks