My QMainWindow contains a QGraphicsView, which should've minimum width and height. So, I've used the following code in the QMainWindow connstructor:
ui.graphicsView->setMinimumHeight(VIEWWIDTH);
ui.graphicsView->setMinimumWidth(VIEWWIDTH);
Then I used following code to set QMainWindow at the center of the screen:
QRect available_geom...
I saw one book on C++ mentioning that navigating inheritance hierarchies using static cast is more efficient than using dynamic cast.
Example:
#include <iostream>
#include <typeinfo>
using namespace std;
class Shape { public: virtual ~Shape() {}; };
class Circle : public Shape {};
class Square : public Shape {};
class Other {};
int ...
My embedded project contains a Qt application for the PC which is mainly a simulator for debugging and testing. In the application I can create several widgets which represent either my embedded software or simulate the hardware controlled by the application or can generate external inputs for testing.
I plan to improve the application ...
Hi,
I've always been a bit confused about how STL containers (vector, list, map...) store values. Do they store references to the values I pass in, or do they copy/copy construct +store the values themselves?
For example,
int i;
vector<int> vec;
vec.push_back(i);
// does &(vec[0]) == &i;
and
class abc;
abc inst;
vector<abc> vec;
ve...
Is there a good 3d realtime software renderer with features similar to OpenGL/DirectX? Something similar of what cairo or anti-grain do for 2d, but in 3d.
I actually just know Mesa witch has a software OpenGL implementation , and Coco3d.
It should be open source :)
...
I am having a bit of trouble organising my source files.
I have my own small, but growing collection of code that I would like to use in various projects. The file and folder layout is something like this:
library\sub1\source.h
library\sub1\source.cpp
library\sub2\source.h
library\sub2\source.cpp
One of my problems is that I want t...
Greetings,
I need to programatically append to a multi-page TIFF or PDF a new image. The problem is that the individual images (that compose the multi-page one) have large resolutions and ImageMagick first loads the entire multi-page image into memory, which takes all the system's memory.
I need to be able to append to a multi-page ima...
Hello,
I'm trying to come up with a way to make the computer do some work for me. I'm using SIMD (SSE2 & SSE3) to calculate the cross product, and I was wondering if it could go any faster. Currently I have the following:
const int maskShuffleCross1 = _MM_SHUFFLE(3,0,2,1); // y z x
const int maskShuffleCross2 = _MM_SHUFFLE(3,1,0,2); //...
Please help me in understanding how exactly the conversion operators in C++ work?
I have a simple example here which I am trying to understand, though it is not very clear how the conversion actually happens by the compiler. Appreciate your time and effort.
Thanks,
Light
#include <iostream>
using namespace std;
class Example
{
public...
I've got a fstream my_file("test.txt"), but I don't know if test.txt exists. In case it exists, I would like to know if I can read it, too. How to do that?
I use Linux.
...
Update: Replaced the destructor example with a straight up method call example.
Hi,
If I have the following code:
class a
{
public:
virtual void func0(); // a has a VTable now
void func1();
};
class b : public a
{
public:
void func0() { a::func0(); }
void func2();
};
Is there a VTable in B? B has no virtual functio...
Reading some questions here on SO about conversion operators and constructors got me thinking about the interaction between them, namely when there is an 'ambiguous' call. Consider the following code:
class A;
class B {
public:
B(){}
B(const A&) //conversion constructor
{
cout << "cal...
Hi. My compiler won't work with an assembly file I have and my other compiler that will won't work with the c files I have. I don't understand assembly. I need to move this over but I'm not getting anywhere fast. Is there someone out there that can help? I can't believe there isn't a translator available. Here is the beginning of the...
Hi,
I need to implement a simple graphical message box for a Linux (SDL) application similar to the Windows MessageBox in C++ (gcc/g++ 4.4.0). All it needs to do is to display a caption, a message and an ok or close button and to return to the calling function when that button is clicked.
SDL just uses X(11) to open a window for (OpenG...
I'm searching for a OpenGL User Interface Library like WxWidgets but not OS dependent.
It would have to provide callbacks for user input since this is OS dependent.
If something like this doesn't yet exist (which I doubt because most games have most of the Basic UI Elements) is there a OpenGL HTML/CSS renderer?
...
Hi,
Currently, I have some code as follows
template<typename Type>
Type* getValue(std::string name, bool tryUseGetter = true)
{
if(tryUseGetter)
{
if(_properties[name]->hasGetter)
{
return (Type*)_properties[name]->getter();
}
return (Type*)_properties[name]->data;
}
else
{
return (Type*)_properties[name]->data;
}
}
...
I'm trying to get rid of floats in my functions.
I have one function that operates on a 16 bit integer value which is an upscaled 8 bit value. Then a downscaled 8 bit is sent to the output.
I'm sure I'm not explaining it well. Something like this:
int8 spot_value = 21; //arbitrary. just need a starting point
int16 running_value;
r...
I've been developing a couple of C# tools recently, but primarily working with a lot of legacy Visual Basic 6.0 code (I know, I know...). For the C# development, I've been using Visual Studio 2008 Professional edition that I downloaded using our MSDN subscription here at work.
But, as a change of pace over the weekend, I was going t...
Is there a difference between 0 and 0.0 in C++? Which should you use for initializing a double?
Thanks
...
If a custom list control is to be developed for S60 5th edition phones, what is the best approach to do that?
The control should enable rich presentation of data in custom layouts. It should be possible to include images, texts, buttons in every item. Each list item should be able to expand/collapse to provide more details about the ite...