Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,20 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.4)
|
||||
|
||||
SET(QT_MIN_VERSION 5.4.0)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
SET(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
FILE ( GLOB sourceFiles *.h *.cpp )
|
||||
|
||||
FIND_PACKAGE(OpenGL)
|
||||
FIND_PACKAGE(Qt5 COMPONENTS Core Gui OpenGL Widgets REQUIRED)
|
||||
|
||||
INCLUDE_DIRECTORIES ( ${QT_INCLUDE_DIR} )
|
||||
|
||||
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
|
||||
|
||||
ADD_EXECUTABLE( GraphicsViewTouchTest WIN32 ${sourceFiles} )
|
||||
|
||||
target_link_libraries( GraphicsViewTouchTest Qt5::Core Qt5::Gui Qt5::OpenGL Qt5::Widgets )
|
||||
@@ -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