c++

Scrolling different Widgets at the same time

Hi all! I have different types of QWidgets into a DockWindow: 1 Qwt plot 1 QWidget 3 QGraphicsView And I need scrolling all of them at the same time with the same scrollbar when I zoom in. I know two solutions for this: Create one scrollbar and connect it to each widget. Create one scrollArea and manipulate all the widgets. What...

Problem in setting up boost library on ubuntu

Hi, I have compiled and installed my boost library in '/media/data/bin' in ubuntu 9.10. And I have setup the INCLUDE_PATH, LIBRARY_PATH env: $ echo $INCLUDE_PATH /media/data/bin/boost/include: $ echo $LIBRARY_PATH /media/data/bin/boost/lib: But when I compile the asio example, I get the following error: $ g++ blocking_tcp_echo_server...

Using bts assembly instruction with gcc compiler

I want to use the bts and bt x86 assembly instructions to speed up bit operations in my C++ code on the Mac. On Windows, the _bittestandset and _bittest intrinsics work well, and provide significant performance gains. On the Mac, the gcc compiler doesn't seem to support those, so I'm trying to do it directly in assembler instead. Here's...

Linking Error When Implementing Templated Based Operator Assignment Function

I try to implement the following function : template<typename T> class a { private: T var; friend bool operator==(const a<T> &, const a<T> &); }; template<typename T> inline bool operator==(const a<T> &r1, const a<T> &r2) { return r1.var==r2.var; } int main () { a<int> var0; a<int> var1; var0 == var1; } Howev...

Strange heap corruption error

I am getting this eror from Visual C++: HEAP[ShockRay3.exe]: Heap block at 00557018 modified at 00557044 past requested size of 24 This occurs when I add a line of code between two recursive calls in a function. All the line of code does is changes a pointer but for some reason every time I put it in, I get this error. This is a simpl...

setCentralWidget() causing the QMainWindow to crash.. Why?

MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { this->setupUi(this); this->setupActions(); this->setWindowTitle(tr("CuteEdit")); label = new QLabel(tr("No Open Files")); this->setCentralWidget(label); label->setAlignment(Qt::AlignCenter); } By above code, I get a GUI like ...

runtime determine type for C++

Hi, I am wondering if type can be determined as runtime information in C++. (1) Although my question is quite general, for simplicity, I will start from a simple example: #include <stdio.h> #include <iostream> #include <cstring> using namespace std; int main(int argc, char * argv[]) { if (strcmp(argv[1], "int")==0)...

how to know whether disk is basic or dynamic?

In windows is it possible to know what kind of disk we are dealing with from a c/c++ program? forget about gpt or mbr, how to know whether it is basic or dynamic? Program input can be drive letter or any info related to disk, output should be dynamic or basic. No need of a direct way of doing, even if it is lengthy process, its okay. I c...

Java Runtime Performance Vs Native C / C++ Code?

I've become more and more comfortable programming in Java than with C++ or C. I am hoping to get a sense of the performance hit incurred using a JVM interpreter, as opposed to executing the same "project" natively. I realize that there is some level of subjectivity here; the quality of the program will depend highly on a good implement...

Profiling C++ with Xcode

Hi, is it possible to profile C++ apps with Xcode so one gets; memory leaks like with valgrind possible errors before running the program Thanks, I am very new to mac and xcode Where can one find a good tutorial for this? ...

Issue writing to Excel file using C++

Hello, We have a requirement to parse a file and write the data to an excel file using C++. I did a search and able to find a project which serves my purpose. http://www.codeproject.com/KB/office/ExcelFormat.aspx Please find a few lines of code below where exactly the errors occur. typedef std::ctype CT; CT const& ct = std::_USE(st...

Insert method of AVL tree?

I am posting you the code for using an AVL tree that I developed. The method for insert, avlinsert method is listed below. I developed this code on paper and it's not tested but I hope this will work. The main problem I want to discuss is the balance factor of the nodes first look at the code. In this way the idea will become clear what ...

Dev C++ Wininet Upload file using HTTP

I want to upload "C:\test.txt" to webserver, when I am running program, file is not uploading and I am not getting any error. the complete C++ code can be find here and php code on webserver can be find here: "http://student114.110mb.com/upload.txt" or "http://student114.110mb.com/upload.php" kindly help me where I am doing wrong ...

Explaining the declaration/definition of HRESULT

I just looked at the definition of HRESULT in VS2008. WinNT.h has the following line: typedef __success(return >= 0) long HRESULT; What exactly does it mean? It doesn't even look like C or C++ to my untrained eye ...

Need help on asynchrous non-blocking file loading with boost::asio and boost::iostreams ( or something different? )

I'm coding in c++, and I'm trying to load an image file asynchronously. After some research, I found some mentions about using boost::asio and boost::iostreams to do it. However, the documentation and example for boost::asio is mostly socket related, so it doesn't help me much. Here is what I need: Load a file asynchronously and upon ...

How to install and use libtool shared library (.lo files)?

So after I ran libtool and got out a libfoo.lo and foo.o file from my library source, how do I convert the libfoo.lo file into a normal Linux shared library, like libfoo.so.1.0.0 so I can install and link to it on my target system? ...

Creating Qt models for tree views

I'm writing an application in Qt (with C++) and I need to represent an object structure in a tree view. One of the ways to do this is to create a model for this, but I'm still quite confused after reading the Qt documentation about the subject. The "structure" I have is pretty simple - there's a Project object that holds Task objects in...

Accelerated C++ exercise: combining a vector of strings

I've been reading Accelerated C++ and I have to say it's an interesting book. In chapter 6, I have to use a function from <algorithm> to concatenate from a vector<string> into a single string. I could use accumulate, but it doesn't help because string containers can only push_back characters. int main () { using namespace std; st...

Change string locale

Hi, I'm not very familiar with locale-specific conversions so I may be using the wrong terminology here. This is what I want to have happen. I want to write a function std::string changeLocale( const std::string& str, const std::locale& loc ) such that if I call this function as follows: changeLocale( std::string( "1.01" ), std::lo...

Operator overloading for a class containing boost::numeric::ublas::matrix<double>

I have a class which contains a few boost::numeric::ublas::matrix's within it. I would like to overload the class's operators (+-*/=) so that I can act on the set of matrices with one statement. However this seems to require temporary instances of my class to carry values around without modifying the original class. This makes sense...