Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Declaration/Definition
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtWidgets/QGraphicsScene>
|
||||
#include <QtWidgets/QGraphicsView>
|
||||
#include <QtWidgets/QGraphicsProxyWidget>
|
||||
#include <QtWidgets/QMessageBox>
|
||||
#include <QtWidgets/QPushButton>
|
||||
#include <QtWidgets/QTextEdit>
|
||||
#include <QtWidgets/QHBoxLayout>
|
||||
|
||||
class View : public QGraphicsView
|
||||
{
|
||||
private:
|
||||
|
||||
QPushButton * m_button;
|
||||
QPushButton * m_reset;
|
||||
QTextEdit * m_console;
|
||||
|
||||
public:
|
||||
|
||||
View(QGraphicsScene * scene, QTextEdit * console, QWidget * parent = nullptr) : QGraphicsView(scene, parent), m_console(console)
|
||||
{
|
||||
setFixedSize( 600, 400 );
|
||||
|
||||
QGraphicsProxyWidget * widgetProxy;
|
||||
|
||||
m_reset = new QPushButton( "Reset", nullptr ); // button must be toplevel widget
|
||||
widgetProxy = scene->addWidget( m_reset );
|
||||
widgetProxy -> setPos( this->mapToScene(150,100) );
|
||||
|
||||
connect(m_reset, &QPushButton::clicked, this, [this]()
|
||||
{
|
||||
this->m_console->append("Reset cursor.\n");
|
||||
this->viewport()->setCursor( Qt::CursorShape::CrossCursor );
|
||||
});
|
||||
|
||||
m_button = new QPushButton( "Touch or Click me \n to change cursor.", nullptr ); // button must be toplevel widget
|
||||
widgetProxy = scene->addWidget( m_button );
|
||||
widgetProxy -> setPos( this->mapToScene(250,200) );
|
||||
|
||||
connect(m_button, &QPushButton::clicked, this, [this]()
|
||||
{
|
||||
this->m_console->append("Button has been clicked --> cursor shape changed to cross cursor.\n");
|
||||
this->viewport()->setCursor( Qt::CursorShape::CrossCursor );
|
||||
update();
|
||||
});
|
||||
|
||||
connect(m_button, &QPushButton::pressed, this, [this]()
|
||||
{
|
||||
this->m_console->append("Button has been pressed.\n");
|
||||
});
|
||||
|
||||
this->viewport()->setCursor( Qt::CursorShape::PointingHandCursor );
|
||||
|
||||
} // View( QGraphicsScene * scene, QWidget * parent = nullptr )
|
||||
|
||||
}; // class View
|
||||
|
||||
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
QApplication app ( argc, argv );
|
||||
|
||||
QApplication::setApplicationName("QGraphicsView Touch Test");
|
||||
|
||||
QGraphicsScene scene;
|
||||
QWidget top;
|
||||
QHBoxLayout * layout = new QHBoxLayout( &top );
|
||||
QTextEdit * console = new QTextEdit( &top );
|
||||
View * view = new View( &scene, console, &top );
|
||||
|
||||
layout->addWidget( view );
|
||||
layout->addWidget( console );
|
||||
|
||||
top.show();
|
||||
|
||||
return app.exec();
|
||||
} // main (int argc, char* argv[])
|
||||
Reference in new issue
Block a user