问题列表 - 第40671页

如何使用AWK在Begin Statement中定义动态数组

我想在我的BEGIN语句中定义一个带有未定义索引号的数组; 我怎么能在AWK中做到这一点?

BEGIN {send_packets_0to1 = 0;rcvd_packets_0to1=0;seqno=0;count=0; n_to_n_delay[];}; 
Run Code Online (Sandbox Code Playgroud)

我有n_to_n_delay []的问题.

awk

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

获取鼠标在QLabel中的位置

在QLabel中获得posa 的最佳(最简单)方法mousePressedEvent是什么?(或者基本上只获取相对于QLabel小部件的鼠标点击位置)

编辑

我尝试了Frank以这种方式建议的内容:

bool MainWindow::eventFilter(QObject *someOb, QEvent *ev)
{
if(someOb == ui->label && ev->type() == QEvent::MouseButtonPress)
{
    QMouseEvent *me = static_cast<QMouseEvent *>(ev);
    QPoint coordinates = me->pos();
    //do stuff
    return true;
}
else return false;
}
Run Code Online (Sandbox Code Playgroud)

但是,我invalid static_cast from type 'QEvent*' to type 'const QMouseEvent*'在我尝试声明的行上收到编译错误me.我在这里做错了什么想法?

c++ qt point-of-sale mousepress

0
推荐指数
1
解决办法
9967
查看次数

Javascript:如何找到id为"map"的h3标题的内容?

我有一个带有Google Map的网页,效果很好.我没有将城市名称硬编码到那里的"波鸿",而是想找到标题

<h3 id="city"><i>Bochum</i></h3>
Run Code Online (Sandbox Code Playgroud)

并在我的init()函数中使用该值.

我可能在下面的代码中遗漏了一些小问题.请帮助我,请参考我对这样一个"孩子"的API参考,我的Javascript技能非常生疏.

我也想知道,我怎样才能通过我的h3标题再传递一个值,就像我的标记的颜色一样?

谢谢!亚历克斯

替代文字

<html>
<head>
<style type="text/css">
        h1,h2,h3,p { text-align: center; }
    #map { width: 400; height: 200; margin-left: auto; margin-right: auto; }
</style>
<script type="text/javascript"
    src="http://maps.google.com/maps/api/js?sensor=false">
</script>
<script type="text/javascript">
function init() {
        for (var child in document.body.childNodes) {
                child = document.body.childNodes[child];
                if (child.nodeName == "H3")
                        alert(child);
        }

    // use the #city value here instead
    city = 'Bochum';

    if (city.length > 1)
        findCity(city);
}

function createMap(center) {
    var opts = {
        zoom: 9,
        center: center, …
Run Code Online (Sandbox Code Playgroud)

javascript dom google-maps

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

将ObservableCollection <>绑定到TextBox

我有以数据形式从Web服务返回的数据,ObservableCollection<string>我希望将集合绑定到只读,TextBox以便用户可以选择数据并将其复制到剪贴板.

要将集合绑定到我创建的TextBox的Text属性,该TextBox IValueConverter将集合转换为文本字符串.这似乎有效,除了它只工作一次,就好像绑定不能识别对Observable集合的后续更改.这是一个简单的应用程序,重现问题,只是为了确认绑定工作正常我还绑定到`ListBox'

这是因为Text绑定简单不处理集合的更改事件吗?

一个选项当然是我处理集合更改并将它们传播到TextBox绑定的Text属性,这很好,但我想理解为什么在我看来是一个明显的解决方案是不行的正如所料.

XAML

<Window x:Class="WpfTextBoxBinding.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:WpfTextBoxBinding"
        Title="MainWindow" Height="331" Width="402">
  <StackPanel>
    <StackPanel.Resources>
      <local:EnumarableToTextConverter x:Key="EnumarableToTextConverter" />
    </StackPanel.Resources>
    <TextBox Text="{Binding TextLines, Mode=OneWay, Converter={StaticResource EnumarableToTextConverter}}" Height="100" />
    <ListBox ItemsSource="{Binding TextLines}" Height="100" />
    <Button Click="Button_Click" Content="Add Line" />
  </StackPanel >
</Window>
Run Code Online (Sandbox Code Playgroud)

代码背后

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using System.Windows;
using System.Windows.Data;
using System.Globalization;

namespace WpfTextBoxBinding
{
  /// <summary>
  /// Interaction logic for MainWindow.xaml
  /// </summary>
  public partial class MainWindow : …
Run Code Online (Sandbox Code Playgroud)

data-binding silverlight wpf ivalueconverter

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

加密密码的最佳方法是什么?

我即将为我的应用程序进行"登录",并想知道为我的用户加密密码的最佳方法是什么,我将在我的数据库中输入?我在Google上找到了很多方法,但不知道哪个是最好的.

c# encryption hash password-protection

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

你不能继承std :: vector

好吧,这真的很难承认,但我现在确实有很强的诱惑力来继承std::vector.

我需要大约10个定制的矢量算法,我希望它们直接成为矢量的成员.但我自然也希望拥有剩下std::vector的界面.好吧,作为一个守法的公民,我的第一个想法是std::vectorMyVector课堂上有一个成员.但是我必须手动重新编写所有std :: vector的接口.打字太多了.接下来,我考虑了私有继承,所以我不会using std::vector::member在公共部分写一些方法而不是重新提取方法.实际上这也很乏味.

在这里,我确实认为我可以简单地从公开继承std::vector,但在文档中提供警告,不应该多态地使用此类.我认为大多数开发人员都有足够的能力去理解这不应该以多态方式使用.

我的决定绝对没有道理吗?如果是这样,为什么?你能提供一个替代方案,其他成员实际上是成员,但不会涉及重新输入所有vector的界面吗?我对此表示怀疑,但如果可以,我会很高兴.

此外,除了一些白痴可以写类似的事实

std::vector<int>* p  = new MyVector
Run Code Online (Sandbox Code Playgroud)

使用MyVector 有任何其他现实危险吗?通过说现实,我放弃像想象一个带有指向矢量的指针的函数...

好吧,我已经陈述了我的情况.我犯罪了.现在由你来原谅我了不起:)

c++ oop inheritance stl vector

182
推荐指数
7
解决办法
5万
查看次数

如何根据文化信息获取日期和时间格式?

我想要的是......如果文化是en-US那么

string dateFormat="MM/dd/yyyy"; 
string timeFormat="24.00 hrs";
Run Code Online (Sandbox Code Playgroud)

如果文化是en-GB那么

string dateFormat="dd/mmyyyy"; 
string timeFormat="24.00 hrs";
Run Code Online (Sandbox Code Playgroud)

等等其他国家..

现在我如何获得这些日期和时间格式值?标准是什么?所有国家都使用类似的日期/时间格式,哪些不使用?

好的我试过这个: -

 DateTime myDate = new DateTime();
   string us = myDate.ToString(new CultureInfo("en-US"));
Run Code Online (Sandbox Code Playgroud)

string us得到值= 1/1/0001 12:00:00 AM

现在如何从我的表格中的Dateformat列中提取"dd/mm/yyyy"和"24.00小时"......我想存储STRINGS,例如dd/mm/yyyy或mm/dd/yyyy NOT dates ..在表格中的TimeFormat列中,要存储的值也是STRINGS,就像我需要存储"24:00hrs"或"12:00hrs"

我现在该怎么办?

**使用ShorTimePattern将这些值返回为

h:mm tt and HH:mm
Run Code Online (Sandbox Code Playgroud)

如果我想将数据库中的值完全存储为"24:00hrs"和"12:00hrs",我该如何使用这些值...... h:mm tt和HH:mm哪一个是24小时格式,哪个是12小时格式?**

好了,现在还有另一个问题......我想要有关Decimal Separator和Thousand Separator的信息也基于CultureInfo ...那个属性是什么?

c# asp.net

50
推荐指数
3
解决办法
12万
查看次数

Android开发:如何让EditText变得简单,所以它只是一个白色方块?

正如标题所说,我看过EditTexts,它们只是纯白色,没有光滑的边角或橙色的android边框,当你突出显示它等.

喜欢它在这个应用程序中看起来:http://s1.appbrain.com/screen?id = -2631427781674403509& i = 1

android view android-edittext

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

使用FPDF通过PHP向PDF附件发送电子邮件

我想通过电子邮件发送PDF作为使用FPDF创建的附件.我的代码看起来像这样,但附件永远不会出现.

<?php
require('lib/fpdf/fpdf.php');

$pdf = new FPDF('P', 'pt', array(500,233));
$pdf->AddFont('Georgiai','','georgiai.php');
$pdf->AddPage();
$pdf->Image('lib/fpdf/giftcertificate.jpg',0,0,500);
$pdf->SetFont('georgiai','',16);
$pdf->Cell(40,10,'Hello World!');
$doc = $pdf->Output('test.pdf', 'S');

//define the receiver of the email
$to = 'myemail@example.com';
//define the subject of the email
$subject = 'Test email with attachment';
//create a boundary string. It must be unique
//so we use the MD5 algorithm to generate a random hash
$random_hash = md5(date('r', time()));
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: reply@test.com\r\nReply-To: …
Run Code Online (Sandbox Code Playgroud)

php pdf attachment fpdf

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

如何使用JS/jQuery控制flash影片

我有一个项目,我有一个movie.swf(AS2)和一些按钮与html部分中的js/jQuery.现在我想要按钮来控制闪光灯.例如,按下Button1将执行gotoAndPlay(1)和Button2 gotoAndPlay(150)Button3 gotoAndStop(450)

Flashmovie使用Actionscript 2.

javascript flash jquery actionscript actionscript-2

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