“无法为未命名的组件创建方法”

2023-12-20

以下代码(在包中注册时)为我们提供了一个名为TParentComponent已登记在托盘中Test.

但是,当您使用属性编辑器(在同一代码中提供)创建子对象时,IDE 会显示错误消息无法为未命名的组件创建方法。

奇怪的是Child对象确实有一个名字。

这是来源:

unit TestEditorUnit;

interface

uses
  Classes, DesignEditors, DesignIntf;

type  
  TParentComponent = class;

  TChildComponent = class(TComponent)
  private
    FParent: TParentComponent;
    FOnTest: TNotifyEvent;
    procedure SetParent(const Value: TParentComponent);
  protected
    procedure SetParentComponent(AParent: TComponent); override;
  public
    destructor Destroy; override;
    function GetParentComponent: TComponent; override;
    function HasParent: Boolean; override;
    property Parent: TParentComponent read FParent write SetParent;
  published
    property OnTest: TNotifyEvent read FOnTest write FOnTest;
  end;

  TParentComponent = class(TComponent)
  private
    FChilds: TList;
  protected
    procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  published
    property Childs: TList read FChilds;
  end;

  TParentPropertyEditor = class(TPropertyEditor)
  public
    function GetAttributes: TPropertyAttributes; override;
    function GetValue: string; override;
    procedure Edit; override;
  end;

procedure Register;

implementation

uses
  ColnEdit;

type
  TChildComponentCollectionItem = class(TCollectionItem)
  private
    FChildComponent: TChildComponent;
    function GetName: string;
    function GetOnTest: TNotifyEvent;
    procedure SetName(const Value: string);
    procedure SetOnTest(const Value: TNotifyEvent);
  protected
    property ChildComponent: TChildComponent read FChildComponent write FChildComponent;
    function GetDisplayName: string; override;
  public
    constructor Create(Collection: TCollection); override;
    destructor Destroy; override;
  published
    property Name: string read GetName write SetName;
    property OnTest: TNotifyEvent read GetOnTest write SetOnTest;
  end;

  TChildComponentCollection = class(TOwnedCollection)
  private
    FDesigner: IDesigner;
  public
    property Designer: IDesigner read FDesigner write FDesigner;
  end;

procedure Register;
begin
  RegisterClass(TChildComponent);
  RegisterNoIcon([TChildComponent]);
  RegisterComponents('Test', [TParentComponent]);
  RegisterPropertyEditor(TypeInfo(TList), TParentComponent, 'Childs', TParentPropertyEditor);
end;

{ TChildComponent }

destructor TChildComponent.Destroy;
begin
  Parent := nil;
  inherited;
end;

function TChildComponent.GetParentComponent: TComponent;
begin
  Result := FParent;
end;

function TChildComponent.HasParent: Boolean;
begin
  Result := Assigned(FParent);
end;

procedure TChildComponent.SetParent(const Value: TParentComponent);
begin
  if FParent <> Value then
  begin
    if Assigned(FParent) then
      FParent.FChilds.Remove(Self);
    FParent := Value;
    if Assigned(FParent) then
      FParent.FChilds.Add(Self);
  end;
end;

procedure TChildComponent.SetParentComponent(AParent: TComponent);
begin
  if AParent is TParentComponent then
    SetParent(AParent as TParentComponent);
end;

{ TParentComponent }

constructor TParentComponent.Create(AOwner: TComponent);
begin
  inherited;
  FChilds := TList.Create;
end;

destructor TParentComponent.Destroy;
var
  I: Integer;
begin
  for I := 0 to FChilds.Count - 1 do
    TComponent(FChilds[0]).Free;
  FChilds.Free;
  inherited;
end;

procedure TParentComponent.GetChildren(Proc: TGetChildProc; Root: TComponent);
var
  i: Integer;
begin
  for i := 0 to FChilds.Count - 1 do
    Proc(TComponent(FChilds[i]));
end;

{ TChildComponentCollectionItem }

constructor TChildComponentCollectionItem.Create(Collection: TCollection);
begin
  inherited;
  if Assigned(Collection) then
  begin
    FChildComponent := TChildComponent.Create(TComponent(TOwnedCollection(Collection).Owner).Owner);
    FChildComponent.Name := TChildComponentCollection(Collection).Designer.UniqueName(TChildComponent.ClassName);
    FChildComponent.Parent := TParentComponent(TComponent(TOwnedCollection(Collection).Owner));
  end;
end;

destructor TChildComponentCollectionItem.Destroy;
begin
  FChildComponent.Free;
  inherited;
end;

function TChildComponentCollectionItem.GetDisplayName: string;
begin
  Result := FChildComponent.Name;
end;

function TChildComponentCollectionItem.GetName: string;
begin
  Result := FChildComponent.Name;
end;

function TChildComponentCollectionItem.GetOnTest: TNotifyEvent;
begin
  Result := FChildComponent.OnTest;
end;

procedure TChildComponentCollectionItem.SetName(const Value: string);
begin
  FChildComponent.Name := Value;
end;

procedure TChildComponentCollectionItem.SetOnTest(const Value: TNotifyEvent);
begin
  FChildComponent.OnTest := Value;
end;

{ TParentPropertyEditor }

procedure TParentPropertyEditor.Edit;
var
  LCollection: TChildComponentCollection;
  i: Integer;
begin
  LCollection := TChildComponentCollection.Create(GetComponent(0), TChildComponentCollectionItem);
  LCollection.Designer := Designer;
  for i := 0 to TParentComponent(GetComponent(0)).Childs.Count - 1 do
    with TChildComponentCollectionItem.Create(nil) do
    begin
      ChildComponent := TChildComponent(TParentComponent(GetComponent(0)).Childs[i]);
      Collection := LCollection;
    end;
  ShowCollectionEditorClass(Designer, TCollectionEditor, TComponent(GetComponent(0)), LCollection, 'Childs');
end;

function TParentPropertyEditor.GetAttributes: TPropertyAttributes;
begin
  Result := [paDialog];
end;

function TParentPropertyEditor.GetValue: string;
begin
  Result := 'Childs';
end;

end.

以上来源改编自StackOverflow 上的另一个答案 https://stackoverflow.com/questions/8406567/creating-a-component-with-named-sub-components.

为什么我无法创建方法的任何想法OnTest?

提前致谢!


设计时间要求汇总

  • 您想要或需要一个能够容纳多个子组件的自定义组件。
  • 这些子组件将由该自定义组件创建。
  • 子组件需要能够像设计时放置的任何普通组件一样在代码中通过其名称进行引用;因此不Form.CustomComponent.Children[0], but Form.Child1反而。
  • 因此,子组件需要在模块(Form、Frame 或 DataModule)的源文件中声明并添加到其中。
  • 子组件由默认的 IDE 集合编辑器管理。
  • 因此,孩子需要被完全包裹在一个TCollectionItem.

当前代码的评估

您已经进展顺利,但除了您的问题之外,代码还有一些需要改进的地方:

  • 您创建的集合永远不会被释放。
  • 每次显示集合编辑器时都会创建一个新集合。
  • 如果从 TreeView 中删除子项,则旧的相应 CollectionItem 会保留,从而生成 AV。
  • 设计时和运行时代码没有分开。

Solution

这是代码的重写的工作版本,具有以下更改:

  • 这个特殊的组件称为Master, 因为Parent与 Delphi 的混淆太多Parent(已经有两种)。因此孩子被称为Slave.
  • 奴隶被关在一个TComponentList (unit Contnrs)以在单个从属破坏的情况下自动更新列表。 ComponentList 拥有从属组件。
  • 对于每一位大师,只会创建一个集合。这些主收藏组合保存在单独的TStockItems对象列表。该列表拥有库存项目,并且该列表在“最终确定”部分中被释放。
  • GetNamePath被实现,以便从属显示为Slave1在对象检查器中,而不是作为SlaveWrappers(0).
  • 为 TSlaveWrapper 类的事件添加了一个额外的属性编辑器。不知何故GetFormMethodName默认的TMethodProperty导致您收到错误。原因将在于Designer.GetObjectName,但我不知道具体原因。现在GetFormMethodName被覆盖,这解决了您问题中的问题。

Remarks

对集合中项目顺序所做的更改(使用集合编辑器的箭头按钮)尚未保留。尝试自己去实现它。

在 TreeView 中,每个 Slave 现在都是 Master 的直接子级,而不是 Master 的子级Slaves属性,如通常在集合中看到的那样:

为了实现这一点,我认为TSlaves应该从TPersistent,并且 ComponentList 将被包装在其中。这肯定是另一个不错的尝试。

元件代码

unit MasterSlave;

interface

uses
  Classes, Contnrs;

type
  TMaster = class;

  TSlave = class(TComponent)
  private
    FMaster: TMaster;
    FOnTest: TNotifyEvent;
    procedure SetMaster(Value: TMaster);
  protected
    procedure SetParentComponent(AParent: TComponent); override;
  public
    function GetParentComponent: TComponent; override;
    function HasParent: Boolean; override;
    property Master: TMaster read FMaster write SetMaster;
  published
    property OnTest: TNotifyEvent read FOnTest write FOnTest;
  end;

  TSlaves = class(TComponentList)
  private
    function GetItem(Index: Integer): TSlave;
    procedure SetItem(Index: Integer; Value: TSlave);
  public
    property Items[Index: Integer]: TSlave read GetItem write SetItem; default;
  end;

  TMaster = class(TComponent)
  private
    FSlaves: TSlaves;
  protected
    procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  published
    property Slaves: TSlaves read FSlaves;
  end;

implementation

{ TSlave }

function TSlave.GetParentComponent: TComponent;
begin
  Result := FMaster;
end;

function TSlave.HasParent: Boolean;
begin
  Result := FMaster <> nil;
end;

procedure TSlave.SetMaster(Value: TMaster);
begin
  if FMaster <> Value then
  begin
    if FMaster <> nil then
      FMaster.FSlaves.Remove(Self);
    FMaster := Value;
    if FMaster <> nil then
      FMaster.FSlaves.Add(Self);
  end;
end;

procedure TSlave.SetParentComponent(AParent: TComponent);
begin
  if AParent is TMaster then
    SetMaster(TMaster(AParent));
end;

{ TSlaves }

function TSlaves.GetItem(Index: Integer): TSlave;
begin
  Result := TSlave(inherited Items[Index]);
end;

procedure TSlaves.SetItem(Index: Integer; Value: TSlave);
begin
  inherited Items[Index] := Value;
end;

{ TMaster }

constructor TMaster.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FSlaves := TSlaves.Create(True);
end;

destructor TMaster.Destroy;
begin
  FSlaves.Free;
  inherited Destroy;
end;

procedure TMaster.GetChildren(Proc: TGetChildProc; Root: TComponent);
var
  I: Integer;
begin
  for I := 0 to FSlaves.Count - 1 do
    Proc(FSlaves[I]);
end;

end.

编辑器代码

unit MasterSlaveEdit;

interface

uses
  Classes, SysUtils, MasterSlave, Contnrs, DesignEditors, DesignIntf, ColnEdit;

type
  TMasterEditor = class(TComponentEditor)
  private
    function Master: TMaster;
  public
    procedure ExecuteVerb(Index: Integer); override;
    function GetVerb(Index: Integer): String; override;
    function GetVerbCount: Integer; override;
  end;

  TMasterProperty = class(TPropertyEditor)
  private
    function Master: TMaster;
  public
    procedure Edit; override;
    function GetAttributes: TPropertyAttributes; override;
    function GetValue: String; override;
  end;

  TOnTestProperty = class(TMethodProperty)
  private
    function Slave: TSlave;
  public
    function GetFormMethodName: String; override;
  end;

  TSlaveWrapper = class(TCollectionItem)
  private
    FSlave: TSlave;
    function GetName: String;
    function GetOnTest: TNotifyEvent;
    procedure SetName(const Value: String);
    procedure SetOnTest(Value: TNotifyEvent);
  protected
    function GetDisplayName: String; override;
  public
    constructor Create(Collection: TCollection); override;
    constructor CreateSlave(Collection: TCollection; ASlave: TSlave);
    destructor Destroy; override;
    function GetNamePath: String; override;
  published
    property Name: String read GetName write SetName;
    property OnTest: TNotifyEvent read GetOnTest write SetOnTest;
  end;

  TSlaveWrappers = class(TOwnedCollection)
  private
    function GetItem(Index: Integer): TSlaveWrapper;
  public
    property Items[Index: Integer]: TSlaveWrapper read GetItem; default;
  end;

implementation

type
  TStockItem = class(TComponent)
  protected
    Collection: TSlaveWrappers;
    Designer: IDesigner;
    Master: TMaster;
    procedure Notification(AComponent: TComponent; Operation: TOperation);
      override;
  public
    destructor Destroy; override;
  end;

  TStockItems = class(TObjectList)
  private
    function GetItem(Index: Integer): TStockItem;
  protected
    function CollectionOf(AMaster: TMaster; Designer: IDesigner): TCollection;
    function Find(ACollection: TCollection): TStockItem;
    property Items[Index: Integer]: TStockItem read GetItem;
      default;
  end;

var
  FStock: TStockItems = nil;

function Stock: TStockItems;
begin
  if FStock = nil then
    FStock := TStockItems.Create(True);
  Result := FStock;
end;

{ TStockItem }

destructor TStockItem.Destroy;
begin
  Collection.Free;
  inherited Destroy;
end;

procedure TStockItem.Notification(AComponent: TComponent;
  Operation: TOperation);
var
  I: Integer;
begin
  inherited Notification(AComponent, Operation);
  if Operation = opRemove then
    for I := 0 to Collection.Count - 1 do
      if Collection[I].FSlave = AComponent then
      begin
        Collection[I].FSlave := nil;
        Collection.Delete(I);
        Break;
      end;
end;

{ TStockItems }

function TStockItems.CollectionOf(AMaster: TMaster;
  Designer: IDesigner): TCollection;
var
  I: Integer;
  Item: TStockItem;
begin
  Result := nil;
  for I := 0 to Count - 1 do
    if Items[I].Master = AMaster then
    begin
      Result := Items[I].Collection;
      Break;
    end;
  if Result = nil then
  begin
    Item := TStockItem.Create(nil);
    Item.Master := AMaster;
    Item.Designer := Designer;
    Item.Collection := TSlaveWrappers.Create(AMaster, TSlaveWrapper);
    for I := 0 to AMaster.Slaves.Count - 1 do
    begin
      TSlaveWrapper.CreateSlave(Item.Collection, AMaster.Slaves[I]);
      Item.FreeNotification(AMaster.Slaves[I]);
    end;
    Add(Item);
    Result := Item.Collection;
  end;
end;

function TStockItems.GetItem(Index: Integer): TStockItem;
begin
  Result := TStockItem(inherited Items[Index]);
end;

function TStockItems.Find(ACollection: TCollection): TStockItem;
var
  I: Integer;
begin
  Result := nil;
  for I := 0 to Count - 1 do
    if Items[I].Collection = ACollection then
    begin
      Result := Items[I];
      Break;
    end;
end;

{ TMasterEditor }

procedure TMasterEditor.ExecuteVerb(Index: Integer);
begin
  case Index of
    0: ShowCollectionEditor(Designer, Master,
      Stock.CollectionOf(Master, Designer), 'Slaves');
  end;
end;

function TMasterEditor.GetVerb(Index: Integer): String;
begin
  case Index of
    0: Result := 'Edit slaves...';
  else
    Result := '';
  end;
end;

function TMasterEditor.GetVerbCount: Integer;
begin
  Result := 1;
end;

function TMasterEditor.Master: TMaster;
begin
  Result := TMaster(Component);
end;

{ TMasterProperty }

procedure TMasterProperty.Edit;
begin
  ShowCollectionEditor(Designer, Master,
    Stock.CollectionOf(Master, Designer), 'Slaves');
end;

function TMasterProperty.GetAttributes: TPropertyAttributes;
begin
  Result := [paDialog];
end;

function TMasterProperty.GetValue: String;
begin
  Result := Format('(%s)', [Master.Slaves.ClassName]);
end;

function TMasterProperty.Master: TMaster;
begin
  Result := TMaster(GetComponent(0));
end;

{ TOnTestProperty }

function TOnTestProperty.GetFormMethodName: String;
begin
  Result := Slave.Name + GetTrimmedEventName;
end;

function TOnTestProperty.Slave: TSlave;
begin
  Result := TSlaveWrapper(GetComponent(0)).FSlave;
end;

{ TSlaveWrapper }

constructor TSlaveWrapper.Create(Collection: TCollection);
begin
  CreateSlave(Collection, nil);
end;

constructor TSlaveWrapper.CreateSlave(Collection: TCollection; ASlave: TSlave);
var
  Item: TStockItem;
begin
  inherited Create(Collection);
  if ASlave = nil then
  begin
    Item := Stock.Find(Collection);
    FSlave := TSlave.Create(Item.Master.Owner);
    FSlave.Name := Item.Designer.UniqueName(TSlave.ClassName);
    FSlave.Master := Item.Master;
    FSlave.FreeNotification(Item);
  end
  else
    FSlave := ASlave;
end;

destructor TSlaveWrapper.Destroy;
begin
  FSlave.Free;
  inherited Destroy;
end;

function TSlaveWrapper.GetDisplayName: String;
begin
  Result := Name;
end;

function TSlaveWrapper.GetName: String;
begin
  Result := FSlave.Name;
end;

function TSlaveWrapper.GetNamePath: String;
begin
  Result := FSlave.GetNamePath;
end;

function TSlaveWrapper.GetOnTest: TNotifyEvent;
begin
  Result := FSlave.OnTest;
end;

procedure TSlaveWrapper.SetName(const Value: String);
begin
  FSlave.Name := Value;
end;

procedure TSlaveWrapper.SetOnTest(Value: TNotifyEvent);
begin
  FSlave.OnTest := Value;
end;

{ TSlaveWrappers }

function TSlaveWrappers.GetItem(Index: Integer): TSlaveWrapper;
begin
  Result := TSlaveWrapper(inherited Items[Index]);
end;

initialization

finalization
  FStock.Free;

end.

注册码

unit MasterSlaveReg;

interface

uses
  Classes, MasterSlave, MasterSlaveEdit, DesignIntf;

procedure Register;

implementation

procedure Register;
begin
  RegisterClass(TSlave);
  RegisterNoIcon([TSlave]);
  RegisterComponents('Samples', [TMaster]);
  RegisterComponentEditor(TMaster, TMasterEditor);
  RegisterPropertyEditor(TypeInfo(TSlaves), TMaster, 'Slaves',
    TMasterProperty);
  RegisterPropertyEditor(TypeInfo(TNotifyEvent), TSlaveWrapper, 'OnTest',
    TOnTestProperty);
end;

end.

封装代码

requires
  rtl,
  DesignIDE;

contains
  MasterSlave in 'MasterSlave.pas',
  MasterSlaveEdit in 'MasterSlaveEdit.pas',
  MasterSlaveReg in 'MasterSlaveReg.pas';
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

“无法为未命名的组件创建方法” 的相关文章

  • 如何在Delphi XE中通过名称获取类类型引用?

    我实际上正在尝试使用 Rtti 来实现通用方法调用程序 它应该像这样工作 我将提供类名 方法名和参数 调用者将通过调用此类的指定方法来完成其工作 因此 我需要类引用才能获取其 Rtti 信息并寻找我想要调用的方法 有没有办法在不实现我想要使
  • 加载 Jpg/Gif/Bitmap 并转换为 Bitmap

    我必须从 XML 文件加载图像 XML 文件中没有关于图像是否为 JPG GIF BMP 的信息 加载图像后 我需要将其转换为位图 有谁知道如何在不知道实际文件格式的情况下将图像转换为位图 我正在使用 Delphi 2007 2009 谢谢
  • Swing:有没有一种方法可以区分用户引起的 ItemEvent 和应用程序引起的 ItemEvent?

    我正在基于 Swing 的应用程序中使用组合框 并且很难弄清楚如何区分由用户事件生成的 ItemEvent 和由应用程序引起的 ItemEvent 例如 假设我有一个组合框 combo 并且我正在使用 ItemListener 监听 ite
  • 在派生类中使属性只读

    我正在重写派生类中的一个属性 我想将其设置为只读 C 编译器不允许我更改访问修饰符 因此它必须保持公共状态 最好的方法是什么 我应该扔一个InvalidOperationException in set 让二传手投掷InvalidOpera
  • Visual C++ MFC 中窗口启动时的事件顺序

    假设我有一个从 CWnd 派生的类 它具有事件处理函数OnPaint OnCreate and OnSize 如您所知 所有这些都是在窗口启动时发生的 但我想看看它们之间的顺序是什么 例如 当我在其中一个中设置断点时 在结束函数后 控制不会
  • 在运行时按需更改组件类

    我的问题与这里的想法类似 替换delphi中的组件类 https stackoverflow com q 4685863 937125 但我需要改变一个specific按需组件类 这是一些伪演示代码 unit Unit1 TForm1 cl
  • 如果移动到不同的子元素上,MouseEvent.offsetX/Y 重置为 0

    采取以下fiddle http jsfiddle net m3Lmvrc0 它包含一个父 div 和 3 个子 div 单击侦听器附加到父 div 并应根据鼠标相对于父 div 的位置发出警报 const parent document g
  • 为什么事件属性不容易获取?

    我有以下代码 HERE https jsfiddle net 5n2zagjc 2 是可编辑的示例 用法 在输入字段中键入并观看控制台 function test event let keys Object keys event let k
  • JavaFX:使用常量字符串前缀绑定 StringProperty

    我对 JavaFX 中的绑定功能有疑问 我想要的是绑定 2 个字符串属性 但他们的价值观不应该是平等的 让我举个例子 我有一个 StringProperty 代表我的应用程序中最后打开的项目 该值类似于 C temp myProject p
  • Delphi - 在修复 VCL 错误时,单元 x 是用不同版本的 x 编译的

    我正在使用 Delphi XE6 并在我的项目中使用 Datasnap 和 JSON 我想纠正 VCL 单元 System JSON pas 在 TJSONString ToString 函数中 中的一个错误 它应该转义反斜杠字符和引号 为
  • 带位图的简单组合框

    如何将位图放入组合框中并将样式设置为简单 例如 Google Chrome 的右侧有星号 Firefox 的右侧有箭头 我尝试了这段代码 procedure TForm2 ComboBox1DrawItem Control TWinCont
  • ZF2 查看攻略

    我正在尝试执行以下操作 简单的控制器和动作 Action 应根据请求返回 2 种类型的响应 HTML in case of ordinary request text html JSON in case of ajax request ap
  • 常量表达式包含无效操作[重复]

    这个问题在这里已经有答案了 我有以下代码 出现错误 PHP 致命错误 常量表达式包含无效操作 当我在构造函数中定义变量时 它工作得很好 我正在使用 Laravel 框架
  • 是否可以删除Android日历事件

    我正在使用 Android 日历 如何使用代码删除日历事件 是否可以 为了澄清起见 我想提一下 我不想要同步过程或想要使用 gdata api 删除事件 我只想删除本地日历事件 尝试使用事件 ID 的 Uri 删除事件 Uri uri UR
  • 是否有用于事件驱动的 Kafka 消费者的 Python API?

    我一直在尝试构建一个以 Kafka 作为唯一界面的 Flask 应用程序 因此 我希望有一个 Kafka 消费者 当相关主题的流中存在新消息时 该消费者会被触发 并通过将消息推回到 Kafka 流来进行响应 我一直在寻找类似 Spring
  • TDictionary 上的 GetItem 由链接器消除

    我正在使用一个TDictionary of
  • TOpenDialog/NSOpenPanel 无法在沙盒 Delphi 应用程序中工作

    Firemonkey 应用程序中的 TOpenDialog 似乎存在问题 该应用程序已针对 Mac Appstore 进行沙箱处理 我使用XE3 但它也存在于XE2中 我其实在这里找到了一份QC报告 但仍然没有解决 http qc emba
  • 我把 IPython 配置文件放在哪里?

    我已经尝试将 edit 编辑器设置为 Emacs 一段时间了 但进展非常缓慢 IPython 0 13 文档不清楚如何实际配置它 它告诉我通过添加将 EDITOR 设置为所需的编辑器 在我的例子中为 emacsclient c get co
  • jQuery 循环与 div 内的寻呼机与点击事件 - 无法停止传播

    我正在使用 jQuery Isotope 插件 在每个可点击 最大化 最小化 同位素元素中 我生成了一个 jQuery Cycle 幻灯片 如下所示 slideshow mainview each function var pager di
  • 石和磅的格式正确吗?

    我有一个图表 用于显示重量 以英石和磅 lbs 为单位 该图表由记录中的数据填充 对于权重 数据类型为 Double 记录数据是在运行时编辑的 我需要知道一种正确格式化输入数据的方法 为了更好地理解 首先看一下这些示例值 它们表示为石和磅

随机推荐

  • 使用@Factory和@DataProvider进行TestNG

    我对 TestNG 和 Java 编程非常陌生 我对一起使用 Factory 和 DataProvider 有疑问 我想测试多次提交网络表单 每次使用不同的输入数据 我有以下代码 public class SolicitudEmpleo e
  • Chart.js:在饼图之外显示标签

    图表 js 2 6 0 我需要渲染一个如下所示的图表 始终显示所有工具提示不是可接受的方式 因为它们不会以正确的方式呈现 不幸的是我还没有找到解决方案 我已经尝试过件标签插件 但这有同样的问题 因为它的标签重叠 我无法隐藏某些标签 这是使用
  • 在 Rails 中保存和检索数组

    我正在 Rails 中开发电子学习 我想将一组数组保存到数据库中 目的是跟踪用户在电子学习各个部分的进度 我遇到过这个问题并回答 在数据库中存储数组 JSON 与序列化数组 https stackoverflow com questions
  • QQuickView - 无延迟/滞后地调整内容大小

    图像通常是解释某事的最简单方法 这是我遇到的问题的一个小屏幕截图 如果您查看窗口的右侧 您可以看到内容大小的调整有明显的滞后 延迟 这是一个在很多应用程序中都会发生的问题 但我想知道是否有办法在 Qt 应用程序中使用QQuickView和
  • 无法添加 gms play 服务 9.0.1,google-services 插件需要 9.0.0

    我的顶级 build gradle 中有这个 buildscript repositories jcenter dependencies classpath com google gms google services 3 0 0 allp
  • 从现有组件中创建自定义 Swing 组件

    所以 我有这个 JTexrtArea 几乎可以完美满足我的需求 唯一的问题是行距 我无法设置它 为什么不使用 JTextPane 因为 JTextArea 中的间距可以更改 而且 JTextArea 比 JTextPane 轻得多 而且我的
  • Play!Framework 中的批量 HTTP 请求

    我已经实施了当前的一组路线 例如 GET api version entity my controllers GET api version entity id my controllers POST api version entity
  • 调用/创建委托

    今天是个好日子 我注意到有两种方法可以调用 创建委托 MrDel MyDelegate new MrDel Mathmetics Method or MrDel MyDelegate Mathmetics Method 所以我的问题是这两种
  • 根据背景图像颜色自动对比文本颜色

    我正在寻找一种方法 根据名为 横幅 的 div 中背景图像的主颜色 将文本颜色更改为 000 或 fff 每个页面上的背景图像都是随机选择的 因此我需要能够自动执行此操作 我碰到JavaScript 颜色对比器 https stackove
  • NoReverseMatch django - 不是有效的视图函数或模式

    目前使用 Django 1 11 我得到一个例外 Reverse for book details not found book details is not a valid view function or pattern name Re
  • 按因子分组并返回其他列的第二低值

    我想按中的值对该数据框进行分组zipcode列 并在另一个 称为比率 列中返回second lowest率或lowest率或max rate 例如 从这个 df zipcode state county code name rate are
  • TypeScript 对数组进行排序

    我一直在试图找出我在打字稿中遇到的一个非常奇怪的问题 它将内联布尔表达式视为第一个值的类型 而不是完整的表达式 因此 如果您尝试如下简单的操作 var numericArray Array
  • 派生的 Scala 案例类与基类具有相同的成员变量

    有更好的方法吗 scala gt case class A x Int defined class A scala gt case class B override val x Int y Int extends A x defined c
  • 如何仅解析特定对象而不反序列化整个 JSON 文件?

    我有一个巨大的 JSON 文件 数万个对象 gt 100 MB 文件 我正在尝试解析以提取特定对象 由于文件太大 我尝试仅反序列化我需要的特定部分 如果可能的话 而不必反序列化整个文件 应根据特定属性的值找到所述对象 arena id xx
  • 在 Android Studio 中搜索整个项目中出现的所有字符串

    我刚刚开始使用 Android Studio IntelliJ 现在我正在寻找该功能来查找项目中任何文件中字符串的出现情况 例如 我想找到所有包含字符串 的文件 getUuid 右上角的搜索没有给我正确的结果 并且我认为我无法在 编辑 gt
  • SQL CE 4 System.Transaction 支持

    有人问了类似的问题here https stackoverflow com questions 3401796 does sql ce 4 ctp support ambient transactions using system tran
  • Python 中的反向索引?

    我知道a 结束 开始 1 以相反的顺序对列表进行切片 例如 a range 20 print a 15 10 1 prints 15 11 print a 15 0 1 prints 15 1 但您无法到达第一个元素 示例中为 0 看来 1
  • 将 Eclipse 迁移到缺少 build.gradle 的 Android Studio

    正如许多人所建议的 我正在尝试从 Eclipse 切换到 Android Studio 遵循以下建议https developer android com sdk installing migrate html https develope
  • 如何在 VSIX 项目中的解决方案文件夹中获取项目

    您好 我在 Visual Studio 扩展内的自定义构建任务遇到问题 我需要识别我的自定义项目类型的项目 如果它们位于解决方案的根目录中 我可以很好地做到这一点 但是当它位于解决方案文件夹内时 就会出现问题 我可以将解决方案文件夹作为 E
  • “无法为未命名的组件创建方法”

    以下代码 在包中注册时 为我们提供了一个名为TParentComponent已登记在托盘中Test 但是 当您使用属性编辑器 在同一代码中提供 创建子对象时 IDE 会显示错误消息无法为未命名的组件创建方法 奇怪的是Child对象确实有一个