bug fixes

This commit is contained in:
xueyan hu
2022-01-25 17:07:34 +08:00
committed by Krad
parent 1f24841ba8
commit 89d237c7d5
4 changed files with 71 additions and 39 deletions

View File

@@ -20,6 +20,8 @@
#include <QSortFilterProxyModel>
#include "src/components/VerticalTextToolButton.h"
#include <QScroller>
#define ADD_CENTER_ITEM(row,col,text)\
item = new QTableWidgetItem(text);\
item->setTextAlignment(Qt::AlignmentFlag::AlignCenter);\
@@ -72,7 +74,9 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) :
table->verticalHeader()->setDefaultSectionSize(38);
table->horizontalHeader()->setStretchLastSection(true);
//data from SQLITE
//
//avoid pan comsumed by tableview!
table->viewport()->ungrabGesture(Qt::PanGesture);
auto model = SQLHelper::getTable("Patient");
model->setFilter("Flag=0");

View File

@@ -72,6 +72,7 @@ int main(int argc, char* argv[])
//QObject::connect(obj, SIGNAL(touchScreen()), Locker::Instance(), SLOT(refreshTimer()));
QList<Qt::GestureType> gestures;
gestures << Qt::SwipeGesture;
gestures << Qt::PanGesture;
w.grabGestures(gestures);
QStringList app_args = a.arguments();

View File

@@ -303,30 +303,55 @@ bool MainWindow::gestureEvent(QGestureEvent* event)
//qCDebug(lcExample) << "gestureEvent():" << event;
if (QGesture* swipe = event->gesture(Qt::SwipeGesture))
swipeTriggered(static_cast<QSwipeGesture*>(swipe));
//else if (QGesture* pan = event->gesture(Qt::PanGesture))
//panTriggered(static_cast<QPanGesture*>(pan));
if (QGesture* pan = event->gesture(Qt::PanGesture))
panTriggered(static_cast<QPanGesture*>(pan));
//if (QGesture* pinch = event->gesture(Qt::PinchGesture))
//pinchTriggered(static_cast<QPinchGesture*>(pinch));
return true;
}
void MainWindow::swipeTriggered(QSwipeGesture* gesture)
void MainWindow::panTriggered(QPanGesture* gesture)
{
if (gesture->state() == Qt::GestureFinished) {
if (gesture->horizontalDirection() == QSwipeGesture::Right) {
QPointF delta = gesture->offset();
int index = tab->currentIndex();
if (delta.x() > 50) {
index--;
if (index >= 0) {
tab->setCurrentIndex(index);
}
}
if (gesture->horizontalDirection() == QSwipeGesture::Left) {
int index = tab->currentIndex();
if (delta.x() < -50)
{
index++;
if (index < tab->count()) {
tab->setCurrentIndex(index);
}
}
qDebug() << "panTriggered" << index;
}
}
void MainWindow::swipeTriggered(QSwipeGesture* gesture)
{
if (gesture->state() == Qt::GestureFinished) {
//if (gesture->horizontalDirection() == QSwipeGesture::Right) {
// int index = tab->currentIndex();
// index--;
// if (index >= 0) {
// tab->setCurrentIndex(index);
// }
//}
//if (gesture->horizontalDirection() == QSwipeGesture::Left) {
// int index = tab->currentIndex();
// index++;
// if (index < tab->count()) {
// tab->setCurrentIndex(index);
// }
//}
if (gesture->verticalDirection() == QSwipeGesture::Down) {
if (debugMode)
{

View File

@@ -15,6 +15,7 @@ class GUIMessageDialog;
class QTabWidget;
class QGestureEvent;
class QSwipeGesture;
class QPanGesture;
class QDockWidget;
class MainWindow : public QMainWindow
@@ -41,6 +42,7 @@ protected:
private:
bool gestureEvent(QGestureEvent* event);
void swipeTriggered(QSwipeGesture*);
void panTriggered(QPanGesture*);
void loadStyleSheet(const QString& sheetName);
cJSON* json_root = nullptr;