Search Results

Search found 15797 results on 632 pages for 'session variables'.

Page 167/632 | < Previous Page | 163 164 165 166 167 168 169 170 171 172 173 174  | Next Page >

  • How to pass variables to slot methods in QT?

    - by Neko
    Hi. I'm making a little chat messenger program, which needs a list of chat channels the user has joined. To represent this list graphically, I have made a list of QPushButtons, which all represent a different channel. These buttons are made with the following method, and that's where my problem kicks in: void Messenger::addToActivePanels(std::string& channel) { activePanelsContents = this->findChild<QWidget *>(QString("activePanelsContents")); pushButton = new QPushButton(activePanelsContents); pushButton->setObjectName("pushButton"); pushButton->setGeometry(QRect(0, 0, 60, 60)); pushButton->setText(""); pushButton->setToolTip(QString(channel.c_str())); pushButton->setCheckable(true); pushButton->setChecked(false); connect(pushButton, SIGNAL(clicked()), this, SLOT(switchTab(channel))); } (activePanelContents is a QWidget that holds the list.) The point is that each button should call the switchTab(string& tabname) method when clicked, including the specific channel's name as variable. This implementation doesn't work though, and I haven't been able to find out how to properly do this, even after reading several pages on it on the internet. Can anybody please tell me how to do this? It'd be greatly appreciated, as always. :)

    Read the article

  • How would you update 100+ variables if something is changed in a different class?

    - by N. Lucas
    I have a class Grid which produces a graph paper like grid on in the drawing area. I then have 5 other classes for different shapes to draw with; Line, Polygon, Ellipse, Curve, Arc Now, these 5 classes use an instance of Grid because Grid has a resolution and a scale. Inside Grid I have: public function set resolution(x:Number):void { _gap = (modBy10(x) / 10); _scale = (modBy10(x) / (this.resolution * _scale)); draw(); } public function get resolution():Number { return (_gap * 10); } public function set scale(x:Number):void { _scale = (this.resolution / x); } public function get scale():Number { return _scale; } /**/ public function scaleLength(x:Number):Number { return (x * this.scale); } public function scaleLengthDown(x:Number):Number { return (x / this.scale); } public function scaleArea(x:Number):Number { return (x / Math.pow(this.scale, 2)); } I'm just lost for a solution on how to update every instance of my 5 drawing classes when Grid is changed. For instance, Polygon is made up of multiple instances of Line, Line(length, angle) where "length" is in either in, ft, cm, or m. If the user wishes to change the scale from say 10ft per 100px resolution.. Is there an easier way than re-drawing every Line inside Polygon?

    Read the article

  • Can g++ fill uninitialized POD variables with known values?

    - by Bob Lied
    I know that Visual Studio under debugging options will fill memory with a known value. Does g++ (any version, but gcc 4.1.2 is most interesting) have any options that would fill an uninitialized local POD structure with recognizable values? struct something{ int a; int b; }; void foo() { something uninitialized; bar(uninitialized.b); } I expect uninitialized.b to be unpredictable randomness; clearly a bug and easily found if optimization and warnings are turned on. But compiled with -g only, no warning. A colleague had a case where code similar to this worked because it coincidentally had a valid value; when the compiler upgraded, it started failing. He thought it was because the new compiler was inserting known values into the structure (much the way that VS fills 0xCC). In my own experience, it was just different random values that didn't happen to be valid. But now I'm curious -- is there any setting of g++ that would make it fill memory that the standard would otherwise say should be uninitialized?

    Read the article

  • how to verify that an old session is really destroyed?

    - by jodeci
    Um, this might sound a bit weird. We were having some problems with a specific browser under a very specific condition, and finally narrowed down the problem to the fact that we were not properly destroying the old sessions after doing session_regenerate_id(). I believe I have solved this problem by doing session_regenerate_id(true) now, but how does one verify that the previous sessions really do not exist any more? Someone suggested cURL but I cannot find my way around their docs. Sadly(?) the boss does not take 'it just works' for an answer so I'd really appreciate any advice!

    Read the article

  • how to add a variables which comes from dataset in for loop Collection array in c#?

    - by leventkalay1986
    I have a collection of RSS items protected Collection<Rss.Items> list = new Collection<Rss.Items>(); The class RSS.Items includes properties such as Link, Text, Description, etc. But when I try to read the XML and set these properties: for (int i = 0; i < dt.Rows.Count; i++) { row = dt.Rows[i]; list[i].Link.Equals(row[0].ToString()); list[i].Description.Equals( row[1].ToString()); list[i].Title.Equals( row[2].ToString()); list[i].Date.Equals( Convert.ToDateTime(row[3])); } I get a null reference exception on the line list[i].Link.Equals(row[0].ToString()); What am I doing wrong?

    Read the article

  • Any way to define getters for lazy variables in Javascript arrays?

    - by LLer
    I'm trying to add elements to an array that are lazy-evaluated. This means that the value for them will not be calculated or known until they are accessed. This is like a previous question I asked but for objects. What I ended up doing for objects was Object.prototype.lazy = function(var_name, value_function) { this.__defineGetter__(var_name, function() { var saved_value = value_function(); this.__defineGetter__(var_name, function() { return saved_value; }); return saved_value; }); } lazy('exampleField', function() { // the code that returns the value I want }); But I haven't figured out a way to do it for real Arrays. Arrays don't have setters like that. You could push a function to an array, but you'd have to call it as a function for it to return the object you really want. What I'm doing right now is I created an object that I treat as an array. Object.prototype.lazy_push = function(value_function) { if(!this.length) this.length = 0; this.lazy(this.length++, value_function); } So what I want to know is, is there a way to do this while still doing it on an array and not a fake array?

    Read the article

  • How can I efficiently retrieve a large number of database settings as PHP variables?

    - by Steven
    Currently all of my script's settings are located in a PHP file which I 'include'. I'm in the process of moving these settings (about 100) to a database table called 'settings'. However I'm struggling to find an efficient way of retrieving all of them into the file. The settings table has 3 columns: ID (autoincrements) name value Two example rows might be: 1 admin_user john 2 admin_email_address [email protected] The only way I can think of retrieving each setting is like this: $result = mysql_query("SELECT value FROM settings WHERE name = 'admin_user'"); $row = mysql_fetch_array($result); $admin_user = $row['value']; $result = mysql_query("SELECT value FROM settings WHERE name = 'admin_email_address'"); $row = mysql_fetch_array($result); $admin_email_address = $row['value']; etc etc Doing it this way will take up a lot of code and will likely be slow. Is there a better way? Thanks.

    Read the article

  • When should I think about implementing my User authentication / session?

    - by Jason N
    After spending some time wireframing my ideas, I want to start building my rails app. However, I'm well aware that later down the line I'd like to consider multiple user accounts. Should I be thinking about the implementation of this from this early stage, or is this something I can implement without too much fuss later? It seems like something that would be stupid to attempt later, but part of me just wants to get the guts of the thing working - a couple of simply forms and writing/reading some stuff from the db.

    Read the article

  • Should member variables of global objects be made global as well?

    - by David Wong
    I'm developing plugins in Eclipse which mandates the use of singleton pattern for the Plugin class in order to access the runtime plugin. The class holds references to objects such as Configuration and Resources. In Eclipse 3.0 plug-in runtime objects are not globally managed and so are not generically accessible. Rather, each plug-in is free to declare API which exposes the plug-in runtime object (e.g., MyPlugin.getInstance() In order for the other components of my system to access these objects, I have to do the following: MyPlugin.getInstance().getConfig().getValue(MyPlugin.CONFIGKEY_SOMEPARAMETER); , which is overly verbose IMO. Since MyPlugin provides global access, wouldn't it be easier for me to just provide global access to the objects it manages as well? MyConfig.getValue(MyPlugin.CONFIGKEY_SOMEPARAMETER); Any thoughts? (I'm actually asking because I was reading about the whole "Global variable access and singletons are evil" debates)

    Read the article

  • How to improve the speed of a loop containing a sqlalchemy query statement as conditional

    - by LtPinback
    This loop checks if a record is in the sqlite database and builds a list of dictionaries for those records that are missing and then executes a multiple insert statement with the list. This works but it is very slow (at least i think it is slow) as it takes 5 minutes to loop over 3500 queries. I am a complete newbie in python, sqlite and sqlalchemy so I wonder if there is a faster way of doing this. list_dict = [] session = Session() for data in data_list: if session.query(Class_object).filter(Class_object.column_name_01 == data[2]).filter(Class_object.column_name_00 == an_id).count() == 0: list_dict.append({'column_name_00':a_id, 'column_name_01':data[2]}) conn = engine.connect() conn.execute(prices.insert(),list_dict) conn.close() session.close() edit: I moved session = Session() outside the loop. Did not make a difference.

    Read the article

  • How to use php variables (arrays) in mysql select statements?

    - by davidconn
    Hi everybody, How do you use a php variable (array) inside a mysql select statement? I am designing an auction site and currently working on a page that lets people view a list of all the current bids for an item. I want to display 3 columns: amountbid - the amount each bidder has bid for the item (held in tblbid) bidderid - the id of each bidder who has bid (found in tbluser) total_positivity_feedback - how many users have left positive feedback for the bidder (calculated from tblfeedback) To find the 'amount' and the 'bidderid' columns i pass the essayid URL parameter from the previous page. This works fine. Despite this, i can't display the total_positivity_feedback column for the various users who have made each bid. My mysql query looks like this: select tblbid.bidderid, tblbid.amount, (select count(tblfeedback.feedbackid) from tblfeedback WHERE tblfeedback.writerid = "ARRAY VARIABLE GOES HERE") AS total_positivity_feedback FROM tblbid WHERE tblbid.essayid = $essayid_bids I assume that the only way to accomplish this is to make the variable contain the bidderid's of those people who bid for that particular essay? I can't seem to work out how to do this tho?!? Many thanks for your help

    Read the article

  • Shuffle array variables in a pre-specified order, without using extra memory of "size of input array"

    - by Eternal Learner
    Input : A[4] = {0,4,-1,1000} - Actual Array P[4] = {1,0,3,2} - Order to be reshuffled Output: A[4] = {4,0,1000,-1} Condition : Don't use an additional array as memory. Can use an extra variable or two. Problem : I have the below program in C++, but this fails for certain inputs of array P. #include<iostream> using namespace std; void swap(int *a_r,int *r) { int temp = *r; *r = *a_r; *a_r = temp; } int main() { int A[4] = {0,4,-1,1000}; int P[4] = {3,0,1,2}; int value = A[0] , dest = P[0]; for(int i=0; i<4;i++) { swap(&A[dest],&value); dest = P[dest]; } for(int i=0;i<4;i++) cout<<A[i]<<" "; }

    Read the article

  • Staticly linked libraries not running code inside to setup static variables.

    - by MJD
    In a c++ project I am working on, I have a simple c++ file that needs to run some code at the beginning of the progam execution. This file is linked into a static library, which is then linked into the main program. I have similar code in other files running fine, that looks something like: bool ____nonexistant_value = executeAction(); However, it does not work inside this file unless I make use of a function implemented in this file. It does work if the library is compilied as a shared library. I'd prefer to link this statically as the library is only a convience as the file is in a different directory.

    Read the article

  • Can't get a List(Of <my class>) from a Dictionary in .NET?

    - by magsto
    I have a Dictionary with key of type UInteger and the value is List(Of Session) where the (Public) class Session contains a couple of variables and a constructor (Public Sub New(...)). Some of the variables in my Session class is: Private count As Integer Private StartDate As Date Private Values As List(Of Integer) and a couple of methods like: Friend Sub Counter(ByVal c as Integer) count += c End Sub There is no problem to add values to the Dictionary: Dim Sessions As New List(Of Session) Dim dict As New Dictionary(Of Integer, Sessions) then some code to fill up a couple of Session objects in Sessions (not shown here) and then: dict.Add(17, Sessions) 'No problem Sessions.Clear() Sessions = dict(17) 'This doesn't return anything! The Sessions object is empty even if the code doesn't returned any error. Is my class Session to compex to be stored in a Dictionary?

    Read the article

  • How to address thread-safety of service data used for maintaining static local variables in C++?

    - by sharptooth
    Consider the following scenario. We have a C++ function with a static local variable: void function() { static int variable = obtain(); //blahblablah } the function needs to be called from multiple threads concurrently, so we add a critical section to avoid concurrent access to the static local: void functionThreadSafe() { CriticalSectionLockClass lock( criticalSection ); static int variable = obtain(); //blahblablah } but will this be enough? I mean there's some magic that makes the variable being initialized no more than once. So there's some service data maintained by the runtime that indicates whether each static local has already been initialized. Will the critical section in the above code protect that service data as well? Is any extra protection required for this scenario?

    Read the article

  • Declare variables that depend on unknown type in template functions.

    - by rem
    Suppose I'm writing a template function foo that has type parameter T. It gets an object of type T that must have method bar(). And inside foo I want to create a vector of objects of type returned by bar. In GNU C++ I can write something like that: template<typename T> void foo(T x) { std::vector<__typeof(x.bar())> v; v.push_back(x.bar()); v.push_back(x.bar()); v.push_back(x.bar()); std::cout << v.size() << std::endl; } How to do the same thing in Microsoft Visual C++? Is there some way to write this code that works in both GNU C++ and Visual C++?

    Read the article

  • What is the best way to pass server side variables to JavaScript on the client side?

    - by steve_c
    Our application uses a lot of configuration options. Those options need to be reflected on the client side in the form of User preferences, site wide preferences, etc. Currently, we pass server side settings down to the client side in the form of JSON that is stored in custom attributes in the markup for a specific element (and no, our application currently doesn't worry about W3C validation). We then retrieve the data from the custom attribute, and parse it into a JSON object for use in script using jQuery. One drawback to this is referencing attributes on elements from within event handlers. I know this is frowned upon, as it can create circular references, and subsequently memory leaks. I would much prefer to use jQuery's data function, but you can't invoke this from the server side at page render time. What does everyone else do in this type of scenario?

    Read the article

  • I can't seem to figure out type variables mixed with classes.

    - by onmach
    I pretty much understand 3/4 the rest of the language, but every time I dip my feet into using classes in a meaningful way in my code I get permantently entrenched. Why doesn't this extremely simple code work? data Room n = Room n n deriving Show class HasArea a where width :: (Num n) => a -> n instance (Num n) => HasArea (Room n) where width (Room w h) = w So, room width is denoted by ints or maybe floats, I don't want to restrict it at this point. Both the class and the instance restrict the n type to Nums, but it still doesn't like it and I get this error: Couldn't match expected type `n1' against inferred type `n' `n1' is a rigid type variable bound by the type signature for `width' at Dungeon.hs:11:16 `n' is a rigid type variable bound by the instance declaration at Dungeon.hs:13:14 In the expression: w In the definition of `width': width (Room w h) = w In the instance declaration for `HasArea (Room n)' So it tells me the types doesn't match, but it doesn't tell me what types it thinks they are, which would be really helpful. As a side note, is there any easy way to debug an error like this? The only way I know to do it is to randomly change stuff until it works.

    Read the article

  • Statically linked libraries not running code inside to setup static variables.

    - by MJD
    In a c++ project I am working on, I have a simple c++ file that needs to run some code at the beginning of the program execution. This file is linked into a static library, which is then linked into the main program. I have similar code in other files running fine, that looks something like: bool ____nonexistent_value = executeAction(); However, it does not work inside this file unless I make use of a function implemented in this file. It does work if the library is compiled as a shared library. I'd prefer to link this statically as the library is only a convenience as the file is in a different directory.

    Read the article

  • What is the point declaring variables at the end of class?

    - by serhio
    I saw multiple examples in MSDN that uses to declare the internal fields at the end of the class. What is the point? I find this a little embarrassing, because each time Visual Studio adds a method it adds it to the end of the class, so there is need every time to move it... class A { public A(){} // Methods, Properties, etc ... private string name; } class A { private string name; public A(){} // Methods, Properties, etc ... }

    Read the article

< Previous Page | 163 164 165 166 167 168 169 170 171 172 173 174  | Next Page >