c++

Update Qt4 statusbar from glwidget

Hi, I've got a window containing a QGLWidget and a QStatusBar. I calculate the fps inside a timerEvent call, but I don't know the 'correct' way to update the statusbar on every frame. fps is a member variable of GLWidget: void GLWidget::timerEvent(QTimerEvent* event){ updateGL(); // Calculate FPS. prevTime = currentTime; ...

Generate uint64_t hash key with several uint32_t integers

Hi everyone, I'm facing the same problem than Eduardo (http://stackoverflow.com/questions/539311/generate-a-hash-sum-for-several-integers) but mine is a little bit different as said in the title. I have four 32bits integers and I need to generate a 64bits unique key. What I have done for now is to generate a string concatenation of the ...

which programming languages support templates like C++?

which programming languages support templates like C++? ...

How is called a C/C++ program without end?

I mean a program based on events, a "static" program that don't just do a task but waits for events, etc. and doesn't end until the user manually close it. EDIT: I have answered below, for example the programs we use every day and are based in Windows, like Microsoft Word, Firefox, etc. What is this type of program called? How is it pos...

[Qt/C++] How do I add a scroll bar to a QMainWindow that has one central widget ?

I wanted to know how can I add a scroll bar to a QMainWindow, when this QMainWindow contains just one central widget, which is bigger than the QMainWindow size .. So that the scroll bar can be used to see different parts of this central widget .. A tutorial would be really beneficial for me at this point .. ...

OpenGL unwanted color fading problem on triangle strip. Want to get uniform color over the triangle

Hello everyone, Here's my problem. I'm drawing a box using a GL_TRIANGLE_STRIP. There is no texture involved, no material and no shaders. I'm just rendering colored triangle. You can see what it looks like here : Fail box But as you can see, I've some clear color fading problem. There is no lighting activated either. Here the code I...

How to build Boost::program_options

I wanted to use boost::program_options. After I installed boost, I think that I have to build separatly program_options (http://www.boost.org/doc/libs/1_43_0/more/getting_started/windows.html). But I don't know how to do it. I am trying to compile the C:\Program Files\boost\boost_1_42\libs\program_options\example\first.cpp (http://www.b...

Linux / C++ Help with glade3 and gtkmm

Here is a C application source code, which creates GUI using Glade3 and GTK2+: // gcc -o simple simple.c $(pkg-config --cflags --libs gtk+-2.0 gmodule-2.0) #include <stdio.h> #include <stdlib.h> #include <string.h> #include <gtk/gtk.h> GtkBuilder *builder; GtkWidget *window1; G_MODULE_EXPORT void on_window1_destroy (GtkObject *obje...

Why so many parentheses in SUCCEEDED macro?

Windows SDK features SUCCEEDED macro: #define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0) -----------------------^-------------^----- clearly as with other macros there're parentheses to ensure right interpretation of the intent by compiler. What I don't get is why there're parentheses around (HRESULT)(hr) (I marked them with ^ character). ...

typeid result across different dll's

Hello, I have two dlls which both declare a templated type, let's call A. If the declaration of A is sufficiently intricate, it happens that the result of typeid(A).name() is different when called in functions in two different dll's. example: DLL1: struct MyType: public A< TEMPLATE_LIST_OF_A >{} void f(){ std::string name1 = typeid(...

When do I use fabs and when is it sufficient to use std::abs?

I assume that abs and fabs are behaving different when using math.h. But when I use just cmath and std::abs, do I have to use std::fabs? or fabs? Or isn't this defined? ...

How to get Driver Name?

Hi, how can I get the driver's name of a device to use with CreateFile? handle = CreateFile( DRIVER_NAME_HERE, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); thanks! ...

Applying a function to 2 stl vectors

I'm currently trying to learn how to effectively use the STL part of c++. Say there are 2 vectors of the same type of equal length that need to be transformed into another vector of the same length by applying some operator, is there a good way to do this using the functionality of the STL? Here's some pseudocode for what I'm trying to ...

how can i declare hdc ?

i copied this code and got an error. plzz tell me how should i declare hDC??? coding: #include "BitmapEx.h" CBitmapEx bitmapEx; bitmapEx.Load(_T("Enter bitmap source file path here...")); bitmapEx.Rotate(45); bitmapEx.Sepia(); bitmapEx.Scale(50, 50); bitmapEx.Draw(hDC); bitmapEx.Save(_T("Enter bitmap destination file path here...")); ...

Answer difference in C

Possible Duplicate: Could anyone explain these undefined behaviors (i = i++ + ++i , i = i++, etc) int a=2,b=3,c; c=a++ + a-- + b++ + b--; printf("%d",c); and int a=2,b=3; int c=a++ + a-- + b++ + b--; printf("%d",c); in first case ans comes 10 but in second case ans comes 12 why? ...

Need help deciphering gprof output

I am pretty sure this has something to do with a vector of void function pointers, but I can't really make anything out of it. Can someone break this down for me? __gnu_cxx::__normal_iterator<unsigned long long const*, std::vector<unsigned long long, std::allocator<unsigned long long> > >::difference_type __gnu_cxx::operator-<unsigned ...

Using DLL import/Declare in VB.NET with parameter types not used by .NET

I am working on a project where I have to import a DLL file into a VB project that was created a few years back. The DLL was created in C++, and looks like: void CoordinateConversionService::convert( SourceOrTarget::Enum sourceDirection, SourceOrTarget::Enum targetDirection, CoordinateTuple* sourceCoordinates, Accuracy* sourceAccuracy, ...

How do I find the current system timezone?

On Linux, I need to find the currently configured timezone as an Olsen location. I want my (C or C++) code to be portable to as many Linux systems as possible. For example. I live in London, so my current Olsen location is "Europe/London". I'm not interested in timezone IDs like "BST", "EST" or whatever. Debian and Ubuntu have a file /...

Better compression algorithm for vector data?

I need to compress some spatially correlated data records. Currently I am getting 1.2x-1.5x compression with zlib, but I figure it should be possible to get more like 2x. The data records have various fields, but for example, zlib seems to have trouble compressing lists of points. The points represent a road network. They are pairs of f...

Possible to combine code coverage results (VC++)

I am using VC++ 2005 and 2008 on a project. Now I want to see if the unit test cases cover all the code, and a found a problem. We use Boost.Test for unit testing, and each file is designed to test a particular function or method. Each file is compiled into a separate executable. I am able to view the results per executable in Visual S...