c++

Qt - QPushButton text formatting

I have a QPushButton and on that I have a text and and icon. I want to make the text on the button to be bold and red. Looked at other forums, googled and lost my hope. Seems there is no way to do that if the button has an icon (of course if you don't creat a new icon wich is text+former icon). Is that the only way? Anyone has a better i...

Is there a list of preprocessor defines for various operating systems (and versions)?

e.g. a mapping for Mac OS 10.6.3 aka Snow Leopard => __APPLE__ && __LP64__? Windows 7, Windows XP => __WIN32__ Linux => __LINUX__ ...

Getting the full-name of the current user, returns an empty string (C#/C++)

I try to get the full-name of the current log-in user (Fullname, not username). The following code C#, C++ works fine but on XP computers not connected to the Net, I get empty string as result if I run it ~20 minutes after login (It runs OK whithin the first ~20 minutes after login) A Win32 API (GetUserNameEx) is used rather that Princi...

boost for each problem

std::map< std::string , std::string > matrix_int; typedef std::pair< std::string , std::string > lp_type; BOOST_FOREACH( lp_type &row, matrix_int ){ } this can not be complied: error C2440: 'initializing' : cannot convert from 'std::pair<_Ty1,_Ty2>' to 'lp_type &' when I have ',' in element type, boost doc says I can use typedef or p...

Please help - sorting integers in structs

I have a struct like this: struct db { string name,sur; int num; }; And declared an array of db structs: struct db a[10]; and every member of a[] is filled with a name, surname and a number but there can be the same number appearing multiple times. I need to sort the numbers, and print the results, i.e. sort by the num of each s...

C++'s unordered_map / hash_map / Google's dense_hash - how to input binary data (buf+len) and insert operation.

Hi all, I have two questions about Google's dense_hash_map, which can be used instead of the more standard unordered_map or hash_map: How do I use an arbitrary binary data memory segment as a key: I want a buffer+length pair, which may still contain some NUL (\0) characters. I can see how I use a NUL-terminated char * string , but tha...

C++0x is assignment of braced-init-list to an array correct?

n3092 (final draft) says, under 5.17/9 A braced-init-list may appear on the right-hand side of - an assignment to a scalar [...] - an assignment defined by a user-defined assignment operator [..] While in GCC 4.5.1-pre9999, I can compile this (using -std=c++0x, NOT -std=gnu++0x) #include <iostream> int main() { ...

How the NPP_NewStream of NPAPI wall called? Automatically or by a plugin-request ?

I have read a lots document on NPAPI but I still do not understand: How the NPP_NewStream of NPAPI wall called? Automatically by Browser, whenever it load a page, an image, an video,.... or manually by our plugin-request ? ...

SIOd: ran out of storage in festival

While running the C++ code for festival,i am using multiple languages like american diaphone,italian etc. but when after playing for one language,i select another language then the terminal shows the error "SIOD:ran out of storage" and does not do anything. Can anyone help me?? ...

C++ - Where to throw exception?

Hello! I have some kind of an ideological question, so: Suppose I have some templated function template <typename Stream> void Foo(Stream& stream, Object& object) { ... } which does something with this object and the stream (for example, serializes that object to the stream or something like that). Let's say I also add some plain wr...

Best XML Library in C++, Fast Set-Up

Hello Everyone, I was wondering what is the best XML Library in C++ (I'm using Visual Studio), considering fast set-up is critical. Basically, I want to create a file to save annotations on various .avi files. Thank you in advance. ...

Mixing libraries with and without RTTI with GCC on Mac OS X?

I've been banging my head on an issue and before I continue injuring myself some more, I'd like to confirm: Is it possible to have a GCC project that uses libraries that are compiled with and without RTTI? So, for example, I have project A (compiled without RTTI) that uses library B (compiled with RTTI) and library C (compiled withou...

Quantization Matrices in x264

I've downloaded the source code and am wading through it --- does anybody know where the QMs for the images and the residuals are stored? ...

Newbie: Minimal program to display a PNG in a window

All, I must have a fundamental neuron missing, but I cannot get a simple program to load a PNG file and display it in a window. I'm not sure if it is a QPixmap, a QPicture, or what. All of the samples in the QTCreator are a bit more than I need right now. Baby steps... I can get the window to display, and the program doesn't barf whe...

Magic++ RGB colors problem

Hi, Does anyone know why is Magic++ giving me RGB values less than 1? Thanks in advance. ...

Logical Programming Problem

Hello, I've been trying to solve this problem for quite sometime but I am having trouble with it. Let's say on a trigger, you receive values. First trigger: You get 1 Second trigger: You get 1, 2 Third trigger: You get 1, 2, 3 So, I store 1. For 2nd trigger, I store 2 since 1 already exist. For 3rd trigger, I store 3 since 1,2 alre...

Windows C++: LPCTSTR vs const TCHAR

In my application i'm declaring a string variable near the top of my code to define the name of my window class which I use in my calls to RegisterClassEx, CreateWindowEx etc.. Now, I know that an LPCTSTR is a typedef and will eventually follow down to a TCHAR (well a CHAR or WCHAR depending on whether UNICODE is defined), but I was wond...

C++: Can't use std::wstringstream

For some reason, my project won't compile when I try to create a wstringstream: std::wstringstream stringstream; This causes error C2079: 'stringstream' uses undefined class 'std::basic_stringstream<_Elem, _Traits, _Alloc> with [_Elem=wchar_t, _Traits=std::char_traits, _Alloc=std::allocator' What am I doing wrong? ...

troubles with boost::asio::io_service::poll()

the following code: /***************************************************************************/ boost::mutex m; struct func { func(int v):n(v) {} void operator()() { { boost::mutex::scoped_lock l(m); std::cout << "run function " << n << std::endl; } for ( int idx = 0; idx < 4; ++idx ) { { ...

C++: Get LPCWSTR from wstringstream?

If I have a wstringstream, and I want to get its .str() data as a LPCWSTR, how can I do that? ...