首页 \ 问答 \ TypeScript Javascript模式(TypeScript Javascript patterns)

TypeScript Javascript模式(TypeScript Javascript patterns)

我正在忙着创建一个meteor.d.ts来支持我在Meteor.js平台上的Typescript开发。 目前的状态可以在这里找到

话虽如此,我有问题抽象两个典型的JavaScript模式。

第一个是Template.myTemplate.events(eventMap) ,其中myTemplate可以由用户动态创建。

其次,能够将其映射到不同的界面。 Meteor使用了很多模式。 例如,当调用Meteor.methods(.. methods ..)时,方法可以访问this.isSimulation(),这在其他任何地方都不可见。

有点难以解释,所以看一下流星文档可能有所帮助

知道如何声明这两种模式吗?

谢谢。


I am busy creating a meteor.d.ts to support my Typescript developments on the Meteor.js platform. Current status can be found here

With that said, I am having issues abstracting two typical javascript patterns.

The first one Template.myTemplate.events(eventMap), where myTemplate can be dynamically created by the user.

Second, the ability to map this to a different interface. Meteor uses the pattern a lot. For instance, when calling Meteor.methods(..methods..), the methods are given access to this.isSimulation() which is not visible anywhere else.

Kind of difficult to explain, so a look at the meteor documentation may help

Any idea how to declare these two patterns?

Thank you.


原文:https://stackoverflow.com/questions/18305763
更新时间:2022-02-25 13:02

最满意答案

您需要做的是调用QLineEdit的setFocus()方法。 见下面的例子,

void MyWidget::on_pushButton_clicked()
{
   ui->lineEdit->setFocus();

}

What you need to do is to invoke the setFocus() method of QLineEdit. See the example below,

void MyWidget::on_pushButton_clicked()
{
   ui->lineEdit->setFocus();

}

相关问答

更多
  • 以下对我来说正常: import sys from PySide import QtCore, QtGui class IPTest(QtGui.QMainWindow): def __init__(self): super(IPTest, self).__init__() self.initUI() def initUI(self): lblAddress = QtGui.QLabel("IP Address", self) ...
  • 您需要做的是调用QLineEdit的setFocus()方法。 见下面的例子, void MyWidget::on_pushButton_clicked() { ui->lineEdit->setFocus(); } What you need to do is to invoke the setFocus() method of QLineEdit. See the example below, void MyWidget::on_pushButton_clicked() { ui->li ...
  • 我认为你可以用QSignalMapper来做你想做的事情。 其目的是映射来自一堆对象的信号并将它们引导到一个插槽,但添加了一个参数来枚举它们来自哪个对象。 我想这正是你想在这里做的。 您只需创建映射器并为每个按钮分配每个按钮和唯一ID。 它避免了为每个按钮创建一个唯一的插槽的需要。 它只适用于原始信号没有任何参数的情况,这对于“点击”信号是正确的,所以它应该适合你。 I think you can do what you want with QSignalMapper. Its purpose is to ...
  • 连接到信号的插槽是同步调用的,因此GUI在返回之前不会更新。 有很多不同的方法可以解决这个问题,但您可以尝试强制执行如下更新: def changepage(self, MainWindow): self.stackedWidget.setCurrentIndex(4) QtGui.qApp.processEvents() 或者,如果这不起作用,请尝试使用单次计时器来运行安装程序: QtCore.QTimer.singleShot(0, lambda: makeinstall(se ...
  • 从源代码: 启动和停止当前不起作用 因此,如果你需要手动停止我不建议你的技巧是重新映射这个插件使用的超时功能或插件本身(这是我的建议)。 要在外部操作超时,您可以执行以下操作: var _setTimeout; var _clearTimeout; var _pauseOn; _setTimeout = window.setTimeout; _clearTimeout = window.clearTimeout; window.setTimeout = function(code, delay) ...
  • 首先:QListWidgetItem没有clicked()信号。 (它本身不是一个小部件)你应该连接到QListWidget :: itemClicked(QListWidgetItem *) - 正如你所看到的,这个信号为你提供了被点击的特定项目。 当然,仅此一项对您没有帮助,因为该项目不知道显示的数据。 您应该使用setData()将信息存储在QListWidgetItem本身中,以便稍后可以从Item中获取它。 但是,由于您可能不希望双重存储数据(一次在myBTwidget中,一次在QListWidg ...
  • QTextEdit的setText函数正确地完成了它的工作:它设置了文本。 如果调用textEdit.setText("2") ,textEdit的文本将变为“2”,并删除上一个文本。 你想要的是QTextEdit.append() 。 它默认写入新行,但有一些解决方法 。 如果您不需要多行,则可以使用QLineEdit 。 The setText function of QTextEdit does it's job correctly: it's set the text. If you call te ...
  • 以下代码应该这样做(在win32下)... EnterCriticalSection( &critSec ); if ( ghThread != INVALID_HANDLE_VALUE ) { ghThread = ::CreateThread( NULL, stackSize, (LPTHREAD_START_ROUTINE)ThreadEntry, NULL, 0, NULL ); } LeaveCriticalSection( &critSec ); 这当然假设您事先将ghThrea ...
  • 使用新的样式信号和插槽(评论的那个),你应该写: self.ui.XSD_path_PB.clicked.connect(self.someMethod) 代替 self.ui.XSD_path_PB.clicked.connect(self.someMethod()) 执行第二行时, self.someMethod()并返回一个值(在您的情况下,默认返回值为None )。 然后,使用此值调用connect 。 它期望这个值是一个python可调用的(一个方法),但它不是(它是None ),所以你得到一 ...
  • 在addItem(self) item是tableWidgetItem类型。 你需要的是QString添加为comboBox项目所以尝试只纠正这一行: item = self.tableWidget.item(0,0).text() 这是工作示例: # -*- coding: utf-8 -*- import sys from PyQt4 import QtCore, QtGui from PyQt4.QtCore import Qt class Widget(QtGui.QWidget): d ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)