小编Val*_*lla的帖子

如何使用Angular 2检查表单中的更改

我有一个包含少量数据字段和两个按钮的表单.我想仅在用户对表单进行一些更改时才启用按钮.我尝试过使用:

this.form.valueChanges.subscribe(data => console.log('form changes', data));
Run Code Online (Sandbox Code Playgroud)

但是,当表单加载时,最初会检测到更改.有没有其他方法来检查表单中的任何更改.我希望仅在用户对字段进行更改时才调用它,而不是在表单加载时调用.以下是我的html和打字稿代码:

profile.html:

<section>
    <div>
        <form [formGroup]="form">
            <fieldset>
                <div class="panel-group m-l-1 m-r-1 accordion vertical-scroll" id="">
                    <div class="form-group required no-gutter">
                        <label for="firstname"> First Name:</label>
                        <div class="col-md-7 col-lg-6">
                            <input type="text" class="form-control" id="firstname" placeholder="" name="firstname" title="firstname" formControlName="firstname" size="128" aria-required="true" maxlength="35">
                        </div>
                    </div>
                </div>

            </fieldset>
            <div>
                <button class="btn btn-primary" type="button" (click)="save()">Save</button>
                <button class="btn btn-primary" type="button" (click)="cancel()">Cancel</button>
            </div>
        </form>
    </div>
</section>
Run Code Online (Sandbox Code Playgroud)

profile.component.ts:

export class ProfileComponent implements OnInit, AfterViewInit, OnChanges {
    public form: FormGroup;

    constructor(private formBuilder: FormBuilder, private app: Application) { …
Run Code Online (Sandbox Code Playgroud)

typescript angular

24
推荐指数
4
解决办法
6万
查看次数

使用python和tkinter在按钮单击上调用python脚本

我有一个python脚本,它具有向用户发送电子邮件的功能.我执行了这个脚本,它工作正常.在另一个python脚本中我只有一个按钮,所以当我点击这个按钮时,我想要另一个发送电子邮件的python脚本来执行.我编写了以下代码:

#!/usr/bin/python
import sys
import os
import Tkinter
import tkMessageBox
top=Tkinter.Tk()

def helloCallBack():
    os.system('SendEmail.py')

B=Tkinter.Button(top,text="hello",command= helloCallBack)
B.pack()
top.mainloop()
Run Code Online (Sandbox Code Playgroud)

单击按钮时出现以下错误:

sh:1:SendEmail.py:找不到.

你能让我知道这个错误的原因是什么以及如何解决它.谢谢.

tkinter python-2.7

11
推荐指数
2
解决办法
2万
查看次数

如何在Qt中覆盖QApplication :: notify

我试图在我的Qt应用程序中处理异常,我经历了几个帖子,这些帖子表明覆盖QApplication :: notify方法以在Qt中以有效的方式处理异常.我不知道我应该在哪里添加这个重写方法.它是mainwindow.h还是main.cpp?我在MainWindow.h中添加了以下函数:

bool
notify(QObject * rec, QEvent * ev)
{
  try
  {
    return QApplication::notify(rec,ev);
  }
  catch(Tango::DevFailed & e)
  {
    QMessageBox::warning(0,
                         "error",
                         "error");
  }

  return false;
}
Run Code Online (Sandbox Code Playgroud)

当我构建我的项目时,我收到以下错误:

error: cannot call member function 'virtual bool QApplication::notify(QObject*, QEvent*)' without object
Run Code Online (Sandbox Code Playgroud)

我是c ++和Qt的新手.如果你让我知道如何实现这一点,那么我的所有异常都将以有效的方式处理,应用程序不会崩溃.

c++ qt exception qtgui qapplication

10
推荐指数
1
解决办法
6470
查看次数

QDataWidgetMapper不能与QLabels一起使用

我正在使用QDataWidgetMapper将数据映射到QLineEdit,它工作正常.当我使用将数据映射到QLabel时,它不会在标签中显示任何数据.我正在尝试以下列方式执行此操作:

QDataWidgetMapper *testMapper=new QDataWidgetMapper();

testMapper->setOrientation(Qt::Vertical);
testMapper->setModel(testModel);


//setting the mapper values to the textboxes ----works fine
testMapper->addMapping(ui->LineEdit1,0);
testMapper->addMapping(ui->LineEdit2,1);

//setting it to qlabels
testMapper->addMapping(ui->label,3);----- does not work
testMapper->toFirst();
Run Code Online (Sandbox Code Playgroud)

我从列表中获取值并将列表附加到QDataWidgetMapper,从mapper我使用addMapping将其附加到文本框.任何人都可以让我知道为什么它不适用于qLabels.

qt qt4 qt-creator

8
推荐指数
1
解决办法
1110
查看次数

在primefaces的行编辑中,event.getObject()将旧值发送给bean

我试图使用主要面孔的功能,允许用户编辑表格本身的行数据.我已经按照这个链接来实现它:

http://www.primefaces.org/showcase/ui/datatableRowEditing.jsf

当我说编辑用户时,输入的新值不会发送到bean.它仍然只显示旧值.

我在JSF中的代码:

<p:dataTable value="#{mybean.userList}"
        var="item"
        id="dataTab"
        widgetVar="usersTable"
        tableStyleClass="data"  paginator="true" rows="5"  
        filteredValue="#{userController.filteredUsers}"
        editable="true"
        rowKey="#{item}">

    <p:ajax event="rowEdit"   listener="#{mybean.onEdit}" update=":userForm:growl" />  
    <p:ajax event="rowEditCancel" listener="#{mybean.onCancel}" update=":userForm:growl" /> 
    <f:facet name="header">
        <p:outputPanel>  
            <h:outputText value="Search all fields:" />  
            <p:inputText id="globalFilter"     onkeyup="('usersTable').filter()"   style="width:150px" />  
        </p:outputPanel>     
    </f:facet>


    <p:column sortBy="#{item.firstName}" filterBy="#{item.firstName}" 
        filterMatchMode="startsWith">
        <p:cellEditor> 
            <f:facet name="header">  
                <h:outputText value="First Name" />  
            </f:facet>
            <f:facet name="output">
                <h:outputText  value="#{item.firstName}" />
            </f:facet>
            <f:facet name="input">  
                <p:inputText value="#{item.firstName}" style="width:100%"/>  
            </f:facet>  
        </p:cellEditor>
    </p:column>
    <p:column  sortBy="#{item.lastName}" filterBy="#{item.lastName}" filterMatchMode="startsWith">
        <p:cellEditor> 
            <f:facet name="header">  
                <h:outputText value="Last Name" />  
            </f:facet>

            <p:column headerText="Update" …
Run Code Online (Sandbox Code Playgroud)

jsf primefaces jsf-2

6
推荐指数
1
解决办法
6026
查看次数

LNK1112:模块机器类型'x64'与目标机器类型'X86'冲突:Qt创建者

我有一个在linux上运行的应用程序,我试图在Windows上导入.我已经设置了所有库,并对.pro文件进行了更改.现在,当我尝试构建项目时,我收到此错误:

error: LNK1112: module machine type 'x64' conflicts with target machine type 'X86'
Run Code Online (Sandbox Code Playgroud)

我不确定是什么导致了这个问题.我使用的是32位Qt创建者.我知道有几个链接谈论改变项目属性,但所有这些都与在Visual Studio中更改它们有关.我正在使用Qt创建者并通过Qt UI运行项目.所以我不确定如果必须解决这个问题,必须通过Qt对项目属性进行哪些更改.

c++ qt qt4 qt-creator

6
推荐指数
1
解决办法
1万
查看次数

如何增加使用bootstrap AngularJs创建的ng-dropdown-multiselect的宽度

我使用AngularJS和bootstrap创建了一个多选下拉列表,并在页面中包含以下代码:

<div class="row">
                    <div class="col-lg-6">
                        <label>Standards</label>
                        <ng-dropdown-multiselect
                                options="dashboard.example1data"
                                selected-model="dashboard.example1model"
                        style="max-width: 500px;">
                        </ng-dropdown-multiselect>
                    </div>
                </div>
Run Code Online (Sandbox Code Playgroud)

我试图增加下拉列表的宽度,我不知道如何实现这一点.有人能让我知道如何增加"ng-dropdown-multiselect"的宽度.

angularjs angular-ui-bootstrap ng-dropdown-multiselect

6
推荐指数
1
解决办法
7510
查看次数

未捕获(承诺):没有空闲的提供者

我在AngularJS 2应用程序中使用ng2-idle.我能够在项目的node_modules文件夹中获取ng2-idle软件包.我正在尝试将其导入我的一个组件,如下所示:

Dashboard.component.ts:

import { Ng2IdleModule } from 'ng2-idle/index';
import { DEFAULT_INTERRUPTSOURCES } from 'ng2-idle/index';
import { Idle } from 'ng2-idle/idle';

//location and router
import { Router } from '@angular/router';


import { AppComponent } from '../../app.component';

@Component({

    selector: 'dashboard',
    templateUrl: './dashboard.component.html'
})

export class DashboardComponent {
    private showBusyIndicator: boolean = false;
    private idleState: string = 'Not started.';
    private timedOut: boolean = false;
    constructor( @Host() @Inject(forwardRef(() => AppComponent)) private app: AppComponent,
        private idle: Idle) {//throws an error when I include it …
Run Code Online (Sandbox Code Playgroud)

typescript angular

5
推荐指数
1
解决办法
7039
查看次数

升级到Angular 5后,对象不支持IE 11中的属性或方法

我最近将应用程序从Angular 4升级到Angular5。该应用程序在chrome中运行良好,但是当我尝试在IE 11中运行该应用程序时,它给了我以下错误,并且页面无法加载。

在此处输入图片说明

以下是我在polyfills.ts中拥有的代码:

/**
 * This file includes polyfills needed by Angular and is loaded before the app.
 * You can add your own extra polyfills to this file.
 *
 * This file is divided into 2 sections:
 *   1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
 *   2. Application imports. Files imported after ZoneJS that should be loaded before your main
 *      file.
 *
 * The current setup is for so-called "evergreen" …
Run Code Online (Sandbox Code Playgroud)

polyfills rxjs angular angular5

5
推荐指数
0
解决办法
2523
查看次数

如何使用PyQt根据屏幕分辨率调整主窗口的大小

我有一个包含三个框架的主窗口。顶部框架包含页眉,底部框架包含页脚。我使用设计器进行PyQt4设计。当我在屏幕分辨率为的笔记本电脑上运行该窗口时,该窗口看起来不错1920*1080。但是,当我在其他分辨率上进行检查时,例如1600*900页脚被切断。我想知道是否有一种方法可以在运行时根据屏幕分辨率调整窗口大小,以便显示所有三个框架。我试图在线检查是否有任何解决方案,但找不到任何解决方案。我尝试使用window.setGeometrywindow.setFixedSize函数,但是没有用。

该窗口的代码是:

import sys
import os
import threading
import smtplib

from PyQt4 import QtCore, QtGui, uic
import sched
import time

form_class = uic.loadUiType("FirstTest.ui")[0]                 # Load the UI
try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    _fromUtf8 = lambda s: s

class MyWindowClass(QtGui.QMainWindow, form_class):
    def __init__(self, parent=None):
        QtGui.QMainWindow.__init__(self, parent)        
        self.setupUi(self)        

#has some code for the field values to be shown







app = QtGui.QApplication(sys.argv)
myWindow = MyWindowClass(None)
#myWindow.setFixedSize(500,500)
myWindow.showMaximized()
palette = QtGui.QPalette()
palette.setColor(QtGui.QPalette.Background,QtCore.Qt.white)
myWindow.setPalette(palette) …
Run Code Online (Sandbox Code Playgroud)

python qt pyqt pyqt4

4
推荐指数
1
解决办法
1万
查看次数