I have a structure:
struct mystruct
{
int* pointer;
};
structure mystruct* struct_inst;
Now I want to change the value pointed to by struct_inst->pointer. How can I do that?
I have a settings bundle, working perfectly, that I would like to customize a bit.
I have, among other things, a PSSliderSpecifier and a PSTitleValueSpecifier.
What I would like to do is change the value of the PSTitleValueSpecifier to show the current value of the slider, preferably updating every time the slider's value changes (Actually, what I'd like even more would be displaying the slider's value on the same row as the slider).
I know the settings bundle is rather strict about what you're allowed to do in it, but is there any way of doing this?
I have subclassed QComboBox to customize it for special needs. The subclass is used to promote QComboBoxes in a ui file from QtDesigner. Everything works except that when I put a break point in a slot, the program does not stop at the breakpoint. I do however know that it is being called from the result it generates. I checked other slots in my program and they work fine with breakpoints. Doing a clean and rebuild all did not fix it. What could be causing this and is there anything I can do about it? The slot in question is the only one in the subclass and is called "do_indexChanged()". You can find the slot on line 37 of the class header below and the signal-slot connection on line 10 of the class source file.
CLASS HEADER:
#ifndef WVQCOMBOBOX_H
#define WVQCOMBOBOX_H
#include <QWidget>
#include <QObject>
#include <QComboBox>
#include <QVariant>
class wvQComboBox : public QComboBox
{
Q_OBJECT
//Q_PROPERTY(bool writeEnable READ writeEnable WRITE setWriteEnable)
public:
explicit wvQComboBox(QWidget *parent = 0);
bool writeEnable() {
return this->property("writeEnable").toBool();
}
void setWriteEnable(const bool & writeEnable){
this->setProperty("writeEnable",writeEnable);
}
bool newValReady() {
return this->property("newValReady").toBool();
}
void setNewValReady(const bool & newValReady){
this->setProperty("newValReady",newValReady);
}
QString getNewVal();
int getNewValIndex();
int oldVal; //comboBox Index before user edit began
private slots:
void do_indexChanged(){
this->setWriteEnable(true);
if(oldVal!=currentIndex()){
this->setNewValReady(true);
oldVal=currentIndex();
}
}
protected:
void focusInEvent ( QFocusEvent * event );
//void focusOutEvent ( QFocusEvent * event );//dont need because of currentIndexChanged(int)
};
#endif // WVQCOMBOBOX_H
#include "wvqcombobox.h"
wvQComboBox::wvQComboBox(QWidget *parent) :
QComboBox(parent)
{
this->setWriteEnable(true);
this->setNewValReady(false);
oldVal=this->currentIndex();
connect(this,SIGNAL(currentIndexChanged(int)),this,SLOT(do_indexChanged()));
}
void wvQComboBox::focusInEvent ( QFocusEvent * event ) {
this->setWriteEnable(false);
oldVal=this->currentIndex();
}
QString wvQComboBox::getNewVal(){
setNewValReady(false);
return this->currentText();
}
int wvQComboBox::getNewValIndex(){
setNewValReady(false);
return this->currentIndex();
}
Can anyone help me with getting data from this plist? I'm having trouble accessing the values of the three objects in the plist.
i can see all the list of countries in my tableView, but i can't see the prices when i tap on a cell .
any help please
thanks
MY PLIST
<plist version="1.0">
<dict>
<key>Afghanistan 3</key>
<array>
<string>RC $1.65</string>
<string>CC $2.36</string>
<string>EC 0</string>
</array>
<key>Albania 1</key>
<array>
<string>RC FREE</string>
<string>CC $1.01</string>
</array>
<key>Algeria 2</key>
<array>
<string>RC $0.27</string>
<string>CC $0.85</string>
</array>
<key>Andorra 2</key>
<array>
<string>RC FREE</string>
<string>CC $0.93</string>
also my code that i have implemented in xcode 4.5 .
cc is the calling rate that is in item 0 in the plist
rc is the receiving rate that is in item 1 in the plist
ec is the extra rate that is in item 2 in the plist
how can i see the cc ,rc, & ec each in a label when i click the cell in the next view controller ?
MY CODE
NSString *ratesFile = [[NSBundle mainBundle] pathForResource:@"rates" ofType:@"plist"];
rates = [[NSDictionary alloc]initWithContentsOfFile:ratesFile];
NSArray * dictionaryKeys = [rates allKeys];
name = [dictionaryKeys sortedArrayUsingSelector:@selector(compare:)];
cc = [rates objectForKey:@"Item 0"];
rc = [rates objectForKey:@"Item 1"];
ec = [rates objectForKey:@"Item 2"];
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [rates count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
NSString *countryName = [name objectAtIndex:indexPath.row];
cell.textLabel.text = countryName;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *ccRate = [cc objectAtIndex:indexPath.row];
if (!self.detailViewController) {
self.detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
}
self.detailViewController.detailItem = ccRate;
[self.navigationController pushViewController:self.detailViewController animated:YES];
}
thank in advance
I'm brand new to Ruby testing and Google isn't helping.
Using Test/Unit, how can I print an instance variable, like
test "thing to happen" do
do_stuff
assert_equal "foo", @variable
p @varible
end
I have the following code:
preg_match_all('/(.*) \((\d+)\) - ([\d\.\d]+)[,?]/U',
"E-Book What I Didn't Learn At School... (2) - 3525.01, FREE Intro DVD/Vid (1) - 0.15",
$match);
var_dump($string, $match);
and get the following ouput:
array(4) {
[0]=>
array(1) {
[0]=>
string(54) "E-Book What I Didn't Learn At School... (2) - 3525.01,"
}
[1]=>
array(1) {
[0]=>
string(39) "E-Book What I Didn't Learn At School..."
}
[2]=>
array(1) {
[0]=>
string(1) "2"
}
[3]=>
array(1) {
[0]=>
string(7) "3525.01"
}
}
which matches only one items... what i need is to get all items from such strings. when i've added "," sign to the end of the string - it worked fine. but that is non-sense in adding comma to each string. Any advice?
I have a wxPython application with the various GUI classes in their own modules in a package called gui. With this setup, importing the main window would be done as follows:
from gui.mainwindow import MainWindow
This looked messy to me so I changed the __init__.py file for the gui package to import the class directly into the package namespace:
from mainwindow import MainWindow
This allows me to import the main window like this:
from gui import MainWindow
This looks better to me aesthetically and I think it also more closely represents what I'm doing (importing the MainWindow class from the gui "namespace"). The reason I made the gui package was to keep all the GUI stuff together. I could have just as easily made a single gui module and stuffed all the GUI classes in it, but I think that would have been unmanageable. The package now appears to work like a module, but allows me to separate the classes into their own modules (along with helper functions, etc.).
This whole thing strikes me as somewhat petty, I just thought I'd throw it out there to see what others think about the idea.
Hi all, I need to able to access controller methods from a model using the Kohana V2.3 framework. At the moment I'm passing the controller object (by ref.) to the model on creation which works perfectly fine but I can't help think there is a more "cleaner" way - does anybody have any suggestions? Would Kohana V3 resolve this with its HMVC pattern?
This may help: http://www.ifc0nfig.com/accessing-the-calling-controller-in-a-model-within-kohana/
I have the following input string:
key1 = "test string1" ; key2 = "test string 2"
I need to convert it to the following without tokenizing
key1="test string1";key2="test string 2"
Hi all,
I am currently Developing application in MVC2
I have want to used mutiple form tags in My application
In My View
I have Created a table which has Delete option which i am doing through Post for Individual Delete so i have Create form tag for each button.
i also want user to give option to delete mutiple records so i am providing them with checkboxes.This form should have all the values of checkboxes and all.
so form gets render Like this
for Each delete button
<form action="/Home/MutipleDelete" method="post">
<input class="button " name="Compare" type="submit" value="Mutipledelete" style="margin-right:132px;" />
<input id="chk1" name="chk1" type="checkbox" value="true" />
<form action="/Home/Delete" method="post">
<input type="submit" class="submitLink" value="member1" />
<input type="hidden" name="hfmem1" id="hfmem1" value="1" />
</form>
<input id="chk2" name="chk2" type="checkbox" value="true" />
<form action="/Home/Delete" method="post">
<input type="submit" class="submitLink" value="member2" />
<input type="hidden" name="hfmem2" id="hfmem2" value="2" />
</form>
</form>
The following is not working . but IF i write my code that form renders in this way
<form action="/Home/MutipleDelete" method="post">
<input class="button " name="Compare" type="submit" value="Mutipledelete" style="margin-right:132px;" />
</form>
<input id="chk1" name="chk1" type="checkbox" value="true" />
<form action="/Home/Delete" method="post">
<input type="submit" class="submitLink" value="member1" />
<input type="hidden" name="hfmem1" id="hfmem1" value="1" />
</form>
<input id="chk2" name="chk2" type="checkbox" value="true" />
<form action="/Home/Delete" method="post">
<input type="submit" class="submitLink" value="member2" />
<input type="hidden" name="hfmem2" id="hfmem2" value="2" />
</form>
it is working in Mozilla but not in IE.I have debug and Checked values in formcollection In contoller.What to do.?
i have an input form which connected to database...
after that i want to make a form to show all data which have been input to database..and this data will show in table and also i can sort the data by name or by date...
please help me...
I'm some trouble adding strings together for a UITextView in my app. The method I've been using is this
(header)
#import <UIKit/UIKit.h>
@interface calculatorViewController : UIViewController {
IBOutlet UITextView *output;
}
-(IBAction)b1;
@property(nonatomic, copy) NSString *output;
@end
(main)
#import "calculatorViewController.h"
@implementation calculatorViewController
-(void)b1 {
[output stringByAppendingString:@"hi"];
}
The problem I've been having with this method is when I use the button the app crashes. The warning it gives me is 'UITextView' may not respond to '-stringByAppendingString:'
When I replace output with at string it works though and that confused me.
Any suggestions? Am I doing something wrong?
Thanks
Disclaimer: absolute novice in Scala :(
I have the following defined:
def tryAndReport(body: Unit) : Unit = {
try {
body
} catch {
case e: MySpecificException => doSomethingUseful
}
}
I call it like this:
tryAndReport{
someCodeThatThrowsMySpecificException()
}
While the call to someCodeThatThrowsMySpecificException happens just fine, the exception is not being caught in tryAndReport.
Why?
Thank you!
So, here is the function for pre-filtering "CHILD":
function(match){
if ( match[1] === "nth" ) {
// parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
!/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
// calculate the numbers (first)n+(last) including if they are negative
match[2] = (test[1] + (test[2] || 1)) - 0;
match[3] = test[3] - 0;
}
// TODO: Move to normal caching system
match[0] = done++;
return match;
}
The code is extracted from line 442-458 of sizzle.js.
So, why is the line var test = ..., have the exec inputing a boolean? Or is that really a string?
Can someone explain it by splitting it into a few more lines of code?
Anybody please give some useful links on this topic.i need to create a content search for my website.. i have tried google but not get useful materials on this topic...please help me
We are in the process of building a 64bit version of our software, but we use Flash player's OCX control to host Flash in our windows. This OCX file is a 32bit build, do you know if it's possible to host this 32bit version of Flash within our 64bit application?
I have a requirement to build an extensible wizard in a portlet. This wizard will list components that are installed and forward the user to a sub-wizard that is component specific.
The requirement is that the components are to be developed by other people and dynamically plugged into this wizard (Jetspeed reboot is okay). I would like to be able to define the components as portlets themselves who's content is rendered into the primary portlet.
Has anybody ever done something like this?
I've been working on this for about an hour and looked at all related SO questions.
My problem is very simple:
I have HomePageVieModel:
HomePageVieModel
+IList<NewsItem> AllNewsItems
+ICommand OpenNewsItem
My markup:
<Window DataContext="{Binding HomePageViewModel../>
<ListBox ItemsSource="{Binding Path=AllNewsItems}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock>
<Hyperlink Command="{Binding Path=OpenNews}">
<TextBlock Text="{Binding Path=NewsContent}" />
</Hyperlink>
</TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
The list shows fine with all the items, but for the life of me whatever I try for the Command won't work:
<Hyperlink Command="{Binding Path=OpenNewsItem, RelativeSource={RelativeSource AncestorType=vm:HomePageViewModel, AncestorLevel=1}}">
<Hyperlink Command="{Binding Path=OpenNewsItem, RelativeSource={RelativeSource AncestorType=vm:HomePageViewModel,**Mode=FindAncestor}**}">
<Hyperlink Command="{Binding Path=OpenNewsItem, RelativeSource={RelativeSource AncestorType=vm:HomePageViewModel,**Mode=TemplatedParent}**}">
I just always get :
System.Windows.Data Error: 4 : Cannot find source for binding with reference .....
Given a Python package, how can I automatically find all its sub-packages?
I used to have a function that would just browse the file system, looking for folders that have an __init__.py* file in them, but now I need a method that would work even if the whole package is in an egg.
while(1){
//Command prompt
char *command;
printf("%s>",current_working_directory);
scanf("%s",command);<--seg faults after input has been received.
printf("\ncommand:%s\n",command);
}
I am getting a few different errors and they don't really seem reproducible(except for the segfault at this point .<). This code worked fine about 10 minutes ago, then it infinite looped the printf command and now it seg faults on the line mentioned above. The only thing I changed was scanf("%s",command); to what it currently is. If I change the command variable to be an array it works, obviously this is because the storage is set aside for it.
1) I got prosecuted about telling someone that they needed to malloc a pointer* (But that usually seems to solve the problem such as making it an array)
2) the command I am entering is "magic" 5 characters so there shouldn't be any crazy stack overflow.
3) I am running on mac OSX 10.6 with newest version of xCode(non-OS4) and standard gcc
4) this is how I compile the program: gcc --std=c99 -W sfs.c
Just trying to figure out what is going on. Being this is for a school project I am never going to have to see again, I will just code some noob work around that would make my boss cry :) But for afterwards I would love to figure out why this is happening and not just make some fix for it, and if there is some fix for it why that fix works.
Hi I need to split list by an argument in Haskell. I found function like this
group :: Int -> [a] -> [[a]]
group _ [] = []
group n l
| n > 0 = (take n l) : (group n (drop n l))
| otherwise = error "Negative n"
But what if lists that I want to divide are contained by another list?
For example
group 3 [[1,2,3,4,5,6],[2,4,6,8,10,12]]
should return
[[[1,2,3],[4,5,6]],[[2,4,6],[8,10,12]]]
Is there any way to do that ?
Continuing my quest of learning Java by doing a simple game, i stumbled upon a little issue. My gameboard extends JPanel as well as each piece of the board. Now, this presents some problems:
Cant set size of each piece, therefore, each piece JPanel ocupy the whole JFrame, concealing the rest of the pieces and the background (gameboard).
Cant set the position of the pieces.
I have the default flow manager. Tried setbounds and no luck.
Perhaps i should make the piece to extend other JComponent?
I've been working on this for about an hour and looked at all related SO questions.
My problem is very simple:
I have HomePageVieModel:
HomePageVieModel
+IList<NewsItem> AllNewsItems
+ICommand OpenNews
My markup:
<Window DataContext="{Binding HomePageViewModel../>
<ListBox ItemsSource="{Binding Path=AllNewsItems}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock>
<Hyperlink Command="{Binding Path=OpenNews}">
<TextBlock Text="{Binding Path=NewsContent}" />
</Hyperlink>
</TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
The list shows fine with all the items, but for the life of me whatever I try for the Command won't work:
<Hyperlink Command="{Binding Path=OpenNewsItem, RelativeSource={RelativeSource AncestorType=vm:HomePageViewModel, AncestorLevel=1}}">
<Hyperlink Command="{Binding Path=OpenNewsItem, RelativeSource={RelativeSource AncestorType=vm:HomePageViewModel,**Mode=FindAncestor}**}">
<Hyperlink Command="{Binding Path=OpenNewsItem, RelativeSource={RelativeSource AncestorType=vm:HomePageViewModel,**Mode=TemplatedParent}**}">
I just always get :
System.Windows.Data Error: 4 : Cannot find source for binding with reference .....
Update
I am setting my ViewModel like this? Didn't think this would matter:
<Window.DataContext>
<Binding Path="HomePage" Source="{StaticResource Locator}"/>
</Window.DataContext>
I use the ViewModelLocator class from the MVVMLight toolkit which does the magic.
Given the very simple wpf app
<Window x:Class="Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="800">
<Grid>
<ToolBar Height="50" >
<MenuItem Header="Test1" />
<MenuItem Header="Test2" />
<StackPanel Orientation="Horizontal">
<Separator />
<MenuItem Header="Test3" />
<MenuItem Header="Test4" />
<MenuItem Header="Test5" />
</StackPanel>
</ToolBar>
</Grid>
</Window>
The Separator element shrinks to nothing. If I put the Separator just before the StackPanel begins, it will show up. Why does this happen? Is there a style setting that can be applied somewhere to avoid this?
Can you please tell me how does this java code work? :
public class Main {
public static void main (String[] args) {
Strangemethod(5);
}
public static void Strangemethod(int len) {
while(len > 1){
System.out.println(len-1);
Strangemethod(len - 1);
}
}
}
I tried to debug it and follow the code step by step but I didn't understand it.