I want to format a selected text in a QTextEdit by clicking a button. For axample I want to make it bold if it is not-bold, or not-bold if it is bold. Please help me with an example.
EDIT:
Actually I have found already a code - qt demo for text editor which does what I need:
void
MyTextEdit::boldText(bool isBold) //this is the SLOT fo...
I have a difference between files size and used disk space (total file size is even more than disk size). I suppose because there are many hard links exist (to WinSxS components) in Windows 7/Vista. But how can I programmatically distinguish hard links from real files in Windows 7?
...
How's this look:
class HugeHack
{
HugeHack() : m_flag( false ) { }
void Logout( )
{
boost::lock_guard< boost::mutex > lock( m_lock );
m_flag = true;
// do stuff that in a perfect world would be atomic with library call and onLogout
// call a library function that waits for a thread to finis...
I found that if you create a file called "usertype.dat" in visual studio's IDE dir, that you can specify keywords that will appear in blue like "new" or "int".
Is there a way to assign values to these?
I don't want to have to use "#define [keyword] [value]" in every single file that I use..
Specifically, I would like to have a "null = ...
If we have:
__int32 some_var = 0;
What is the best (if any) way to call InterlockedExchange, InterlockedIncrement and other interlocked functions which require LONG* for some_var ?
Since, there is guarantee that LONG is 32 bit on any Windows, it's probably safe just to pass (long*) some_var. However, it seems to me quite ugly and I c...
I have an "array" of bytes that is referenced in some high-level client/developer documentation (which does not contain any programming language or environment specific information). In this document, bytes are currently referred to as "byte 3" or "byte 17", etc. The development environment is C/C++ and the bytes are stored in an array i...
I have gotten the GLUT 3.7 source and opened the MSVC project. I switched DLL to static lib in the project settings and got a lib. I then linked against it in my application, and added the GLUT_STATIC preprocessor definition. It creates the window and renders one frame of my game and that's it. Whereas the game runs just fine with the dy...
Hi,
in this code:
int foo() {
static int x;
}
is the x global to all threads or local in each thread? Or does that depends on a compiler flag and/or the compiler, so I cannot really know what it is from the code?
Several questions (all of them independent from compiler and compiler flags and OS):
How can I create a static varia...
I am having an issue with a 32-bit legacy app running on 64-bit windows. The app in question uses CreateFileMapping to create shared memory. When this is run on 64-bit Windows any attempt to access this shared memory from another process takes about 1 second. The shared memory is created using page protection flags:
flProtect = PAGE_REA...
I have an Windows C++ application which has a memory leak. I am pretty sure the leak is in one of our (many) linked libraries. I have instrumented the global new and delete function in our app and the app calls to allocate memory seem fine. They account for about 10% of the process working set though.
When I walk the heaps
// http://...
Greetings,
How can I simply encode some binary data into an ASN.1 DER-encoded blob? I'm using C/C++, and I figure it should be possible to simply prefix the binary blob with some appropriate bytes that signify that the data is of type octet string and is of a given length (and in a sequence of length 1 I guess).
Background if you're i...
Good morning all,
I'm searching for a very fast binary serialization technique for c++. I only need to serialize data contained in objects (no pointers etc.). I'd like it to be as fast as
possible. If it's specific to x86 hardware that's acceptable.
I'm familiar with the C methods of doing this. As a test I've bench marked a couple of ...
Hi, I need to store types in a list with one identifier for each one;
I need a random access to the elements of the list without knowing the identifier at compilation time
I tried the meta-programming typelist but I don't know how to return types with the identifier, i get compilation error :
'cannot appear in a constant-expression'
...
In this simple example, why do I need to make 'member' const in order to get this to compile?
struct ClassA
{
ClassA(int integer) {}
};
struct ClassB
{
ClassB(int integer):
member(integer)
{
}
const ClassA& member;
};
int main()
{
ClassB* b = new ClassB(12);
return 0;
}
Otherwise, I get this err...
I got some trouble with bitfields and endian stuff...
I confused.
I need to parse some data got from the network, the sent are in lil endian (im using boost::asio)
Can you explain me this
struct TEST
{
unsigned short _last : 1;
unsigned short _ID : 6;
unsigned short _LENGH : 9;
};
struct TEST2
{
unsigned short _LENGH:9 ;
unsigne...
Hey! check out the following example.. its almost a copy paste from some cpp book.
i can't understand why is doesn't compile (under windows).
it says:
'<<' : no operator found which takes a right-hand operand of type 'div_t' (or there is no acceptable conversion)
this is the example:
#include <iostream>
template <class T>
T div(T ...
I am looking for existing implementations of different types of DES in C/C++/C##. My running platform is Windows XP/Vista/7.
I am trying to write a C# program which will encrypt and decrypt using the DES algorithm. I need some implementations with which i can verify my code output to see if i did the things in right order. For the imple...
Is there a way to create a vector< mem_fun_t< ReturnType, MyClass > > ?
The error i'm seeing is:
error C2512: 'std::mem_fun1_t<_Result,_Ty,_Arg>' : no appropriate default constructor available
...
I have data coming over a socket that looks like this:
(h)(int,char,float,int,char)(/h)(d)(2,a,1.32,45,d)(3,d,3.45,32,a)(/d)
The datatype of the data arriving is dynamic and is only known when the header is received. I then have to create corresponding std::vectors to store the data. In this case, two int, two char and one float vecto...
Hi,
I'm building a shared library with f-no-rtti. Internally, this library throws std:invalid_argument and catches std::exception, but the catch clause is never entered.
The following code reproduces the problem (g++ 4.2, Mac OS X 10.6):
// library.cpp: exports f(), compiled with -fno-rtti
#include <stdexcept>
#include <iostream>
exte...