Is there any way to prevent the NSTokenField to select everything when pressing the ENTER key or when making to the first responder maybe using the TAB key?
So I'm pretty new to Qt, and I've just inherited a project from someone else who is also new to Qt. He isn't around this week btw. We are using Visual Studio 2008, and have the latest version of Qt installed(4.6.2).
The project builds on my coworker's machine fine, and I can get the project from svn and build it directly. But under any other circumstances it refuses to build on my machine, and it doesn't give me much of an explanation why. Even if I just do a 'build clean' and then a 'build' it doesn't work. Any slight modification will make it fail.
When I try to build the entire project I get the error message:
1Moc'ing MatrixTypeInterface.h...
1moc: Cannot create
.\GeneratedFiles\Debug\moc_MatrixTypeInterface.cpp;.\GeneratedFiles\Debug\moc_matrixtypeinterface.cpp
1Project : error PRJ0019: A tool
returned an error code from "Moc'ing
MatrixTypeInterface.h..."
The moc tool doesn't give any sort of error message as to why it isn't working, and I wasted most of yesterday trying to figure out why. I got the command that VS was using to call moc, and I entered in the command line myself. It didn't write anything to the screen.
Any ideas?
We are just migrating from D7 to D2010 and are having a debate about cleaning up the project paths. We have a number of directories with a large number of Pas files that are included on some project paths, but only a few of the files are actually used by any single project.
One option is to eliminate the project paths completely and only have all used files in the dpr.
The second option is to keep only the needed files in the dpr and have project paths to the directories for the rest of the files.
Is there any argument for one option over the other?
I could understand the following search algorithms:
Constraint Satisfaction with Arc Consistency,
Uninformed search
A* Search
MinMax
I would understand the definition and working principles of the above algorithm,but could you please give me some real world examples that the above algorithms will be suitable?My idea would be: For CSP with Arc Consistency,assign students to groups that each group must contain both technical and management students,and no 2 technical students in a same group.
Uniformed Search: search for a file under UNIX directoy.
A* Search: search a way (staring from home) to go to mulitple stores to buy things then get back home with minimum total travelling time.
MinMax:Go or other Chess.
Please correct me if I am wrong.
Recently I have noticed a number of questions on SO that look something like this:
I am writing a small program to keep a
list of the songs that I keep on my
ipod. I'm thinking about writing it
as a 3-tier MVC Ruby on Rails web
application with TDD, DDD and IOC,
using a factory pattern to create the
classes and a singleton to store my
application settings. Do you think
I'm taking the right approach?
Do you think that we're handing novice programmers a very sharp knife and telling them, "Don't cut yourself with this"?
NOTE: Despite the humorous tone, this is a serious (and programming-related) question.
say ive got a matrix that looks like:
[[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]
how can i make it on seperate lines:
[[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0]]
and then remove commas etc:
0 0 0 0 0
And also to make it blank instead of 0's, so that numbers can be put in later, so in the end it will be like:
_ 1 2 _ 1 _ 1
(spaces not underscores)
thanks
In-process HSQLDB database are not expected to be opened by others, even for file-based storage.
The documentation hints that this is possible: Server Modes, Advanced Topics, but I've not yet found a URL for how to activate this behaviour.
Did anyone do this so they can share how to?
I'm trying to designing a class and I'm having issues with accessing some of the nested fields and I have some concerns with how multithread safe the whole design is. I would like to know if anyone has a better idea of how this should be designed or if any changes that should be made?
using System;
using System.Collections;
namespace SystemClass
{
public class Program
{
static void Main(string[] args)
{
System system = new System();
//Seems like an awkward way to access all the members
dynamic deviceInstance = (((DeviceType)((DeviceGroup)system.deviceGroups[0]).deviceTypes[0]).deviceInstances[0]);
Boolean checkLocked = deviceInstance.locked;
//Seems like this method for accessing fields might have problems with multithreading
foreach (DeviceGroup dg in system.deviceGroups)
{
foreach (DeviceType dt in dg.deviceTypes)
{
foreach (dynamic di in dt.deviceInstances)
{
checkLocked = di.locked;
}
}
}
}
}
public class System
{
public ArrayList deviceGroups = new ArrayList();
public System()
{
//API called to get names of all the DeviceGroups
deviceGroups.Add(new DeviceGroup("Motherboard"));
}
}
public class DeviceGroup
{
public ArrayList deviceTypes = new ArrayList();
public DeviceGroup() {}
public DeviceGroup(string deviceGroupName)
{
//API called to get names of all the Devicetypes
deviceTypes.Add(new DeviceType("Keyboard"));
deviceTypes.Add(new DeviceType("Mouse"));
}
}
public class DeviceType
{
public ArrayList deviceInstances = new ArrayList();
public bool deviceConnected;
public DeviceType() {}
public DeviceType(string DeviceType)
{
//API called to get hardwareIDs of all the device instances
deviceInstances.Add(new Mouse("0001"));
deviceInstances.Add(new Keyboard("0003"));
deviceInstances.Add(new Keyboard("0004"));
//Start thread CheckConnection that updates deviceConnected periodically
}
public void CheckConnection()
{
//API call to check connection and returns true
this.deviceConnected = true;
}
}
public class Keyboard
{
public string hardwareAddress;
public bool keypress;
public bool deviceConnected;
public Keyboard() {}
public Keyboard(string hardwareAddress)
{
this.hardwareAddress = hardwareAddress;
//Start thread to update deviceConnected periodically
}
public void CheckKeyPress()
{
//if API returns true
this.keypress = true;
}
}
public class Mouse
{
public string hardwareAddress;
public bool click;
public Mouse() {}
public Mouse(string hardwareAddress)
{
this.hardwareAddress = hardwareAddress;
}
public void CheckClick()
{
//if API returns true
this.click = true;
}
}
}
I'm trying to port a library that uses ucontext over to a platform which supports pthreads but not ucontext. The code is pretty well written so it should be relatively easy to replace all the calls to the ucontext API with a call to pthread routines. However, does this introduce a significant amount of additional overhead? Or is this a satisfactory replacement. I'm not sure how ucontext maps to operating system threads, and the purpose of this facility is to make coroutine spawning fairly cheap and easy.
So, question is: Does replacing ucontext calls with pthread calls significantly change the performance characteristics of a library?
I have a class which calls getaddrinfo for DNS look ups. During testing I want to simulate various error conditions involving this system call. What's the recommended method for mocking system calls like this? I'm using Boost.Test for my unit testing.
Similar to this question about iterating over subroutine references, and as a result of answering this question about a OO dispatch table, I was wondering how to call a method reference inside a reference, without removing it first, or if it was even possible.
For example:
package Class::Foo;
use 5.012; #Yay autostrict!
use warnings;
# a basic constructor for illustration purposes....
sub new {
my $class = shift;
return bless {}, $class;
}
# some subroutines for flavor...
sub sub1 { say 'in sub 1' }
sub sub2 { say 'in sub 2' }
sub sub3 { say 'in sub 3' }
# and a way to dynamically load the tests we're running...
sub sublist {
my $self = shift;
return [
$self->can('sub1');
$self->can('sub3'};
$self->can('sub2');
];
}
package main;
my $instance = Class::Foo->new(a => 1, b => 2, c => 3);
my $tests = $instance->sublist();
my $index = int(rand($#{$tests}));
# <-- HERE
So, at HERE, we could do:
my $ref = $tests->{$index};
$instance->$ref();
but how would we do this, without removing the reference first?
I have a number of classes that look like this:
class Foo(val:BasicData) extends Bar(val) {
val helper = new Helper(val)
val derived1 = helper.getDerived1Value()
val derived2 = helper.getDerived2Value()
}
...except that I don't want to hold onto an instance of "helper" beyond the end of the constructor. In Java, I'd do something like this:
public class Foo {
final Derived derived1, derived2;
public Foo(BasicData val) {
Helper helper = new Helper(val);
derived1 = helper.getDerived1Value();
derived2 = helper.getDerived2Value();
}
}
So how do I do something like that in Scala? I'm aware of creating a helper object of the same name of the class with an apply method: I was hoping for something slightly more succinct.
Let's say I have circle bouncing around inside a rectangular area. At some point this circle will collide with one of the surfaces of the rectangle and reflect back. The usual way I'd do this would be to let the circle overlap that boundary and then reflect the velocity vector. The fact that the circle actually overlaps the boundary isn't usually a problem, nor really noticeable at low velocity. At high velocity it becomes quite clear that the circle is doing something it shouldn't.
What I'd like to do is to programmatically take reflection into account and place the circle at it's proper position before displaying it on the screen. This means that I have to calculate the point where it hits the boundary between it's current position and it's future position -- rather than calculating it's new position and then checking if it has hit the boundary.
This is a little bit more complicated than the usual circle/rectangle collision problem. I have a vague idea of how I should do it -- basically create a bounding rectangle between the current position and the new position, which brings up a slew of problems of it's own (Since the rectangle is rotated according to the direction of the circle's velocity). However, I'm thinking that this is a common problem, and that a common solution already exists.
Is there a common solution to this kind of problem? Perhaps some basic theories which I should look into?
I have a wget like script which downloads a page and then retrieves all the files linked in img tags on that page.
Given the URL of the original page and the the link extracted from the img tag in that page I need to build the URL for the image file I want to retrieve. Currently I use a function I wrote:
sub build_url {
my ( $base, $path ) = @_;
# if the path is absolute just prepend the domain to it
if ($path =~ /^\//) {
($base) = $base =~ /^(?:http:\/\/)?(\w+(?:\.\w+)+)/;
return "$base$path";
}
my @base = split '/', $base;
my @path = split '/', $path;
# remove a trailing filename
pop @base if $base =~ /[[:alnum:]]+\/[\w\d]+\.[\w]+$/;
# check for relative paths
my $relcount = $path =~ /(\.\.\/)/g;
while ( $relcount-- ) {
pop @base;
shift @path;
}
return join '/', @base, @path;
}
The thing is, I'm surely not the first person solving this problem, and in fact it's such a general problem that I assume there must be some better, more standard way of dealing with it, using either a core module or something from CPAN - although via a core module is preferable. I was thinking about File::Spec but wasn't sure if it has all the functionality I would need.
How can I search a dynamic array of char in Delphi 6 for a sub-string and get back an index to a match, not a pointer? I've seen functions in Delphi 6 that do this for strings but not for dynamic char arrays. There is a function called SearchBuf but that function returns a PChar pointer to the match location when what I need is the array index of the match.
Thanks.
everyone:
I have an ASP.NET Application that uses a Repeater control to display a thumbnail gallery. When the user mouses over one of the thumbnails, the main image will present that thumbnail.
It uses a Repeater control in a UserControl like this:
<asp:Image ID="pictureImage" runat="server" Visible="true" Width="200px" />
<asp:Repeater ID="rpProductImages" runat="server" Visible="false">
<ItemTemplate>
<div>
<div style="float: left" id="smallImage" runat="server">
<div class="smallAltImage" onmouseover="showImage();"
style="border: 1px solid #999999; margin: 5px 5px 5px 4px;
width: 45px; height: 45px; background-position: center; background-repeat: no-repeat;
background-image: url('<%#ResolveClientUrl(productImagesPath)%><%# String.Format("{0}", DataBinder.Eval(Container.DataItem, "ImageName")) %>');">
</div>
<asp:Label ID="lblImageName" runat="server" Visible="false"><%# Eval("ImageName")%></asp:Label>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
Then, in a javascript file, this:
function showImage(){
// Get thumbnail path.
var img = (this.style.backgroundImage).substring(4, (this.style.backgroundImage).length - 1);
$('#ctl00_ContentPlaceHolder1_ProductDetails1_pictureImage').attr('src', img);
}
It works fine in IE9, displaying the fully-qualified path for the image. In FireFox8, however, the img src looks like this: ""ProductImages/K42JY_500.jpg"" ... with two-sets of quotes!
I think that the Repeater control is the central cause of the problem but I Googled and Googled again and could not find anyone that has experienced this similar situation!
In fact, I'll PayPal anyone who can help me solve this with $50.00 (can't you tell I'm in the XMAS spirit, here?!)
Any help is appreciated and "Thank You" in advance!
I have a project that is being written on top of the Grape API framework in ruby. (https://github.com/intridea/grape)
The problem I'm having is that Thinking-Sphinx vs. Sunspot (Gems used to interface with each search index) have worlds different benchmarks.
View the Benchmark Here
We're trying to develop something that is quick and easy to deploy (Solr needs Java).
The issues we see right now is mainly that Solr is slower through Sunspot gem and Sphinx is faster through Thinking-Sphinx because Solr is HTTP REST calls where Sphinx is sockets.
Anyone have any experience in either and can explain pitfalls / bonuses?
Note: Needs to be deployable to Rails AND non-rails apps (Hence Sunspot).
Thanks!
Hello all! I am trying to make an app that will only be viewed in Landscape. I have looked up some tutorials (albeit older ones) and have done the following:
-set up the info.plist to include a key for uiinterfaceorientation
-in the main view controller I have set the frame to be 480 x 320
Now, the first screen loads up ok. Everything is where it should be and whatnot. However, if I click a button that is set to present a modal view controller nothing happens. Everything is linked and coded correctly but nothing happens when I press the button. Am I doing something wrong with trying to force landscape?
At it's basic, this question is a how do you effectively make an app that will only be in landscape mode? Thanks for any help.
I'm refactoring some client-server code and it uses the terms Response, Result & Reply for the same thing (an answer from the server). And although its not really that important it's become hard to guess which word to use while writing new code, so I'd like to unify the three terms into one and do the appropriate refactoring, but I'm not sure which word is the "best", if there is such a thing.
Any suggestions based on precedence and standards towards naming for this case?
I'm receiving "culture name 'uploads' is not supported" when my asp.net app start. Where I have to view/debug to toggle the error? A full-text for "uploads" returns o entries in my project
I have a need to create a utility in Suze Linux. The utility will make modifications to some text files, and then use the information in those text files to program a device in the computer using a different executable which accepts command line parameters.
I am fluent in c#, but have never worked with Linux. Should I take the time to learn Gnu C++ to do this, or install Mono? How would I execute the programming utility and pass it command line parameters?
The Boost.Test documentation and examples don't really seem to contain any non-trivial examples and so far the two tutorials I've found here and here while helpful are both fairly basic.
I would like to have a master test suite for the entire project, while maintaining per module suites of unit tests and fixtures that can be run independently. I'll also be using a mock server to test various networking edge cases.
I'm on Ubuntu 8.04, but I'll take any example Linux or Windows since I'm writing my own makefiles anyways.
Looking at this C# code...
byte x = 1;
byte y = 2;
byte z = x + y; // ERROR: Cannot implicitly convert type 'int' to 'byte'
The result of any math performed on byte (or short) types is implicitly cast back to an integer. The solution is to explicitly cast the result back to a byte, so...
byte z = (byte)(x + y); // works
What I am wondering is why? Is it architectural? Philosophical?
We have:
int + int = int
long + long = long
float + float = float
double + double = double
So why not:
byte + byte = byte
short + short = short ?
A bit of background:
I am performing a long list of calculations on "small numbers" (i.e. < 8) and storing the intermediate results in a large array. Using a byte array (instead of an int array) is faster (because of cache hits). But the extensive byte-casts spread through the code make it that much more unreadable.
If i have a header file foo.h and a source file foo.cpp, and foo.cpp contains something along the lines of:
#ifdef WIN32
class asdf {
asdf() { startup_code(); }
~asdf() { cleanup_code(); }
};
asdf __STARTUP_HANDLE__
#else
//unix does not require startup or cleanup code in this case
#endif
but foo.h does not define class asdf, say i have an application bar.cpp:
#include "foo.h"
//link in foo.lib, foo.dll, foo.so, etc
int main() {
//do stuff
return 0;
}
If bar.cpp is compiled on a WIN32 platform, will the asdf() and ~asdf() be called at the appropriate times (before main() and at program exit, respectively) even though class asdf is not defined in foo.h, but is linked in through foo.cpp?