我正在尝试像这样在 ios 上使用 qt 手势:
#ifndef SWIPESTACKWIDGET_H
#define SWIPESTACKWIDGET_H
#include <QStackedWidget>
#include <QSwipeGesture>
class SwipeStackWidget : public QStackedWidget
{
Q_OBJECT
public:
explicit SwipeStackWidget(QWidget *parent = 0);
bool event(QEvent *event);
bool gestureEvent(QGestureEvent *event);
void swipeTriggered(QSwipeGesture *gesture);
signals:
public slots:
};
#endif // SWIPESTACKWIDGET_H
和
#include "swipestackwidget.h"
#include <QDebug>
SwipeStackWidget::SwipeStackWidget(QWidget *parent) :
QStackedWidget(parent)
{
setAttribute(Qt::WA_AcceptTouchEvents);
grabGesture(Qt::TapGesture);
grabGesture(Qt::TapAndHoldGesture);
grabGesture(Qt::PanGesture);
grabGesture(Qt::PinchGesture);
grabGesture(Qt::SwipeGesture);
}
bool SwipeStackWidget::event(QEvent *event)
{
if (event->type() == QEvent::Gesture)
return gestureEvent(static_cast<QGestureEvent*>(event));
return QWidget::event(event);
}
bool SwipeStackWidget::gestureEvent(QGestureEvent *event)
{
qDebug() << "gestureEvent():" << event->gestures().size();
if (QGesture *swipe = event->gesture(Qt::SwipeGesture))
swipeTriggered(static_cast<QSwipeGesture *>(swipe));
if (QGesture *pan = event->gesture(Qt::PanGesture))
qDebug() << "Pan";
if (QGesture *pinch = event->gesture(Qt::PinchGesture))
qDebug() << "Pinch";
if (QGesture *pinch = event->gesture(Qt::TapGesture))
qDebug() << "Tap";
if (QGesture *pinch = event->gesture(Qt::TapAndHoldGesture))
qDebug() << "Tapandhold";
return true;
}
void SwipeStackWidget::swipeTriggered(QSwipeGesture *gesture)
{
qDebug() << "swipeTriggered()";
if (gesture->state() == Qt::GestureFinished) {
if (gesture->horizontalDirection() == QSwipeGesture::Left) {
qDebug() << "swipeTriggered(): swipe to previous";
setCurrentIndex( std::max( 0, currentIndex()-1) );
} else if (gesture->horizontalDirection() == QSwipeGesture::Right) {
qDebug() << "swipeTriggered(): swipe to next";
setCurrentIndex( std::min( count()-1, currentIndex()+1) );
}
update();
}
}
我可以编译代码并在iphone上执行。我确实可靠地接收到制表符手势和 tabAndHold。 Pan 和 Pimch 有时确实会发生。滑动是个大问题:
有没有人有在 ios 上使用 QGestures 的经验并且可以帮助我?
我的测试类直接在主窗口中使用,我也在主窗口中使用 grabGestures 命令,但我不在那里处理手势。
最佳答案
我可以确认它需要三个手指。我在 iPad 上使用 PyQt Qt5.3.1 进行了测试。 (此外,平移需要两根手指。)
我怀疑 Qt 是那样设计的,所以跨平台是一样的(选择 Ubuntu 上常见的手指计数,因为 Canonical 可能贡献了很多代码?)
在 iOS SDK 中,一些基本手势类可针对手指数量和方向进行配置。 Read more.这是唯一相关的,因为它意味着 Qt 可以轻松配置 Qt 订阅的原生手势,如果他们订阅原生手势的话。您可以查看 Qt 的代码(针对 iOS 平台抽象 QPA 和他们的其他手势相关代码)来验证他们是否设计了 3 个手指进行滑动(这不是错误。)
但是iOS平台上的三指向上滑动物理手势应该是“隐藏应用程序并显示系统托盘”的意思吧? (这是我的经验,我无法引用 iOS HIG,也不知道 App Store 的要求。)如果是这样,那么应用程序应该订阅 Qt 的滑动手势并遵循指南。
但是您也可以在 Qt 中为单指滑动实现识别器吗?
关于c++ - iOS 上的 QGestures,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24725088/
我的瘦服务器配置了nginx,我的ROR应用程序正在它们上运行。在我发布代码更新时运行thinrestart会给我的应用程序带来一些停机时间。我试图弄清楚如何优雅地重启正在运行的Thin实例,但找不到好的解决方案。有没有人能做到这一点? 最佳答案 #Restartjustthethinserverdescribedbythatconfigsudothin-C/etc/thin/mysite.ymlrestartNginx将继续运行并代理请求。如果您将Nginx设置为使用多个上游服务器,例如server{listen80;server
我想设置一个默认日期,例如实际日期,我该如何设置?还有如何在组合框中设置默认值顺便问一下,date_field_tag和date_field之间有什么区别? 最佳答案 试试这个:将默认日期作为第二个参数传递。youcorrectlysetthedefaultvalueofcomboboxasshowninyourquestion. 关于ruby-on-rails-date_field_tag,如何设置默认日期?[rails上的ruby],我们在StackOverflow上找到一个类似的问
我将我的Rails应用程序部署到OpenShift,它运行良好,但我无法在生产服务器上运行“Rails控制台”。它给了我这个错误。我该如何解决这个问题?我尝试更新rubygems,但它也给出了权限被拒绝的错误,我也无法做到。railsc错误:Warning:You'reusingRubygems1.8.24withSpring.UpgradetoatleastRubygems2.1.0andrun`gempristine--all`forbetterstartupperformance./opt/rh/ruby193/root/usr/share/rubygems/rubygems
我正在尝试从Postgresql表(table1)中获取数据,该表由另一个相关表(property)的字段(table2)过滤。在纯SQL中,我会这样编写查询:SELECT*FROMtable1JOINtable2USING(table2_id)WHEREtable2.propertyLIKE'query%'这工作正常:scope:my_scope,->(query){includes(:table2).where("table2.property":query)}但我真正需要的是使用LIKE运算符进行过滤,而不是严格相等。然而,这是行不通的:scope:my_scope,->(que
这里有一个很好的答案解释了如何在Ruby中下载文件而不将其加载到内存中:https://stackoverflow.com/a/29743394/4852737require'open-uri'download=open('http://example.com/image.png')IO.copy_stream(download,'~/image.png')我如何验证下载文件的IO.copy_stream调用是否真的成功——这意味着下载的文件与我打算下载的文件完全相同,而不是下载一半的损坏文件?documentation说IO.copy_stream返回它复制的字节数,但是当我还没有下
我正在尝试解析一个文本文件,该文件每行包含可变数量的单词和数字,如下所示:foo4.500bar3.001.33foobar如何读取由空格而不是换行符分隔的文件?有什么方法可以设置File("file.txt").foreach方法以使用空格而不是换行符作为分隔符? 最佳答案 接受的答案将slurp文件,这可能是大文本文件的问题。更好的解决方案是IO.foreach.它是惯用的,将按字符流式传输文件:File.foreach(filename,""){|string|putsstring}包含“thisisanexample”结果的
如何将send与+=一起使用?a=20;a.send"+=",10undefinedmethod`+='for20:Fixnuma=20;a+=10=>30 最佳答案 恐怕你不能。+=不是方法,而是语法糖。参见http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_expressions.html它说Incommonwithmanyotherlanguages,Rubyhasasyntacticshortcut:a=a+2maybewrittenasa+=2.你能做的最好的事情是:
1.错误信息:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:requestcanceledwhilewaitingforconnection(Client.Timeoutexceededwhileawaitingheaders)或者:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:TLShandshaketimeout2.报错原因:docker使用的镜像网址默认为国外,下载容易超时,需要修改成国内镜像地址(首先阿里
我对如何计算通过{%assignvar=0%}赋值的变量加一完全感到困惑。这应该是最简单的任务。到目前为止,这是我尝试过的:{%assignamount=0%}{%forvariantinproduct.variants%}{%assignamount=amount+1%}{%endfor%}Amount:{{amount}}结果总是0。也许我忽略了一些明显的东西。也许有更好的方法。我想要存档的只是获取运行的迭代次数。 最佳答案 因为{{incrementamount}}将输出您的变量值并且不会影响{%assign%}定义的变量,我
我有一个.pfx格式的证书,我需要使用ruby提取公共(public)、私有(private)和CA证书。使用shell我可以这样做:#ExtractPublicKey(askforpassword)opensslpkcs12-infile.pfx-outfile_public.pem-clcerts-nokeys#ExtractCertificateAuthorityKey(askforpassword)opensslpkcs12-infile.pfx-outfile_ca.pem-cacerts-nokeys#ExtractPrivateKey(askforpassword)o