Skip to content

C++ Gurus

The forum for all discussions in C++ land.
1.3k Topics 8.5k Posts
  • 1 Votes
    4 Posts
    5k Views
    N
    I was able to get QtCreator to run on the target machine, simply by hooking up an internet cable to it. I don't know why. So now I can build my application on the target machine. It works fine as long as I build in Debug mode, but in Release mode, it fails - exactly the same way. I have opened up a new thread for this specific problem.
  • How to avoid type comparision using polymorphism

    11
    0 Votes
    11 Posts
    4k Views
    D
    Seems like I closed my browser before sending my last message. Anyway, thank you very much, Volker! I thought it would create a variable per instance, but it makes sense that there is only one static variable per class. It's probably the best way I can implement it. It's solved now!
  • Qt libs linking impact on speed of C++ code

    12
    0 Votes
    12 Posts
    4k Views
    H
    You can see the code of main.cpp in gui branch. (The link is at the first post). If the --no-gui option is passed, the code path is redirected to not run the GUI loop and the program will run as the CLI version do. What I've asked is about the no-GUI mode of GUI version, not its GUI mode. The GUI mode actually runs slower because of GUI stuff but I think I can not do anything about that. GUI needs to display progress so we don't feel it is frozen while it's indexing files.
  • Qt Eclipse Integration iostream unresolved inclusion

    3
    0 Votes
    3 Posts
    6k Views
    C
    here is why: http://qt-project.org/forums/viewthread/4345 do a search on "fstream" or "iostream" and get many hits figured out code-tags @ x=y; z=0; @
  • [Moved] Template error

    6
    0 Votes
    6 Posts
    3k Views
    F
    I would "merge" the two files into the matrix.h .... I am pretty sure that you need to move the implementation of the methods to "inside the class" declaration, something like @ class Matrix { // use signature from .h void myethod() { //however was declared on the cpp file // ... } ... }; @
  • Qsqlquery problem [Solved]

    3
    0 Votes
    3 Posts
    2k Views
    M
    hi, pls set the thread to solved. edit the topic header and write [Solved] in front of it! br
  • 0 Votes
    5 Posts
    2k Views
    G
    You can DEFINE everything, so there is no way to tell whether adding "staticlib" to DEFINES is an error or desired.
  • QList has no virtual destructor, but is inherited from

    14
    0 Votes
    14 Posts
    9k Views
    A
    [quote author="Asperamanca" date="1334737610"] However, I feel you still missed my point regarding copy constructors. I'll sum it up in one sentence, and leave it at that: "A base class cannot know it has to call the copy constructor of a derived class." That a derived class has to call the copy constructor of its base class is clear.[/quote] Well, but that is a moot point, isn't it? It would be impossible for any class to copy into it the members of a derived class. So, a base class doesn't need to know how to call the copy constructor of derived classes. And yes, that means that you have trouble with polymorphism, in that you can't clone a derived class using the copy constructor or assignment operator if you just have a base class pointer. Meyers suggest creating a virtual clone() method for that that returns a pointer instead of a reference, but you obviously can't do that for QList. [quote author="Asperamanca" date="1334734252"]I get a MyDerivedList<MyType>, but store it as a QList<MyType>. When I cause a deep-copy now (e.g. by changing data), which copy constructor(s) will be called? Edit: Answering my own question: It wouldn't do the "right thing" regardless of whether I used QList<MyType> or QList*<MyType>. A way to get polymorphism to work in this case would be the virtual constructor idiom, which however has to be supported in the base class.[/quote] Indeed: the virtual clone method. Note that it's not even possible to do without using pointers to the lists either. You cannot assign a MyDerivedList<MyType> to a QList<MyType> at all. Polymorphism needs pointers or references to work its magic, right?
  • Progressbar problem

    10
    0 Votes
    10 Posts
    7k Views
    R
    thank sir for suggestion . i can use busy Progress bar but for the record i m invoking my_app::progress() using following signal/slot mechanism : @ connect(&my_app,SIGNAL(started()),this,SLOT(progress())); my_app.start(program,arguments); @
  • Overloading QDataStream & operator<< , operator>> in namespace

    3
    0 Votes
    3 Posts
    6k Views
    G
    I'm not a namespace expert, but from my understanding: QDataStream is in global Namespace (or Qt namespace). So I would try ::QDataStream, as QDataStream would refer to a member within your current namespace. Albeit, Andre is correct: Why do you need to implement the operators in the first place?
  • How to ensure comparison operator is "complete"?

    13
    0 Votes
    13 Posts
    5k Views
    A
    I think it's the same one I stumbled upon. ;-)
  • How can I interrupt a function?

    15
    0 Votes
    15 Posts
    13k Views
    N
    All I'm doing is simulating a function that might hang. The following function blocks all timers in all threads in the system until it is finished. If you replace the for loop with while(true), it will block all timers in all threads forever. @ bool HardwareManager::myFunc() { double a; for (int i = 0; i < 100; i++) { for (unsigned j = 0; j < 10000000; j++) { a += j * 3.0; } } qDebug() << "finishing myFunc"; return true; } @ Edit: please use code tags around code sections; Andre
  • QLocalServer with Win32 pipe

    3
    0 Votes
    3 Posts
    3k Views
    A
    Look the catchcopy explorer plugin code, I have do that's.
  • [SOLVED] capture the output of a class

    5
    0 Votes
    5 Posts
    3k Views
    T
    I played today with the above and i figure it out. thanks
  • [Solved][Moved] The size of variables seems to be different than expected

    7
    0 Votes
    7 Posts
    4k Views
    B
    Maybe you'd like to sg like this: @ #include <iostream> using namespace std; struct mainStruct { unsigned char a; int b; unsigned char c; }; struct sharedStruct { unsigned char byteValue[75]; } attribute((may_alias)) ; void print(mainStruct* x) { cout << x->a << endl; cout << x->b << endl; cout << x->c << endl; } int main() { mainStruct ms; //print(&ms); sharedStruct* ss = reinterpret_cast<sharedStruct*>(&ms); ss->byteValue[0] = 22; ss->byteValue[1] = 0; ss->byteValue[2] = 0; ss->byteValue[3] = 0; ss->byteValue[4] = 1; ss->byteValue[5] = 23; ss->byteValue[6] = 1; ss->byteValue[7] = 0; print(reinterpret_cast<mainStruct*>(ss)); return 0; } @
  • Ocr in c++

    11
    0 Votes
    11 Posts
    18k Views
    M
    I have used Tesseract with Qt and OpenCV (2.04): Look at the dlltest project that comes with Tesseract. You can make a .so ( or .dll ) to use in your project My approach ( which have achieved best results ) is preprocess the desired image with text, and pass only the ROIs with the text. The result was good but far below commercial packages... But, if want to implement your own OCR engine, you must have a good knowledge in all of the following technologies: 1 - Image segmentation ( OpenCV ??? ) 2 - Feature extraction ( OpenCV ??? ) 3 - Good algorithm for feature grouping 4 - Text line detection 5 - Character chopping 6 - Character recognition ( see Neural Network for Recognition of Handwritten Digits in codeproject ) 7 - Dictionary based context sentece composer ( QRegexp have good support for this ) 8 - Context analyzer
  • Operator aliases not known?

    6
    0 Votes
    6 Posts
    3k Views
    W
    @mlong: 'not': undeclared identifier The compiler doesn't have a token that he can associate with the word 'not'. @volker: I'm not a 100% sure, though I dont think so. Compiling in C mode would mean that any C++ code that's not C code cannot be compiled. Following this reasoning, then no, I'm not compiling in C mode. Also, I'm running the QtCreator standards, which logically would be auto-set to C++. I can't seem to find a switch that would enable the use of operator alternatives. I've tried a few compilers on different systems today, and it seems that all compilers running on Windows machine do not normally support the use of alternative operator names (MinGW, MSVC++). The Intel and GNU compilers on Linux (Fedora 15: G++, Scientific 5: Intel) and Mac (Leopard: G++, Intel) do. Including the ISO646.h header file solves the problem, albeit not an elegant solution.
  • Why does the following recursive directory creation fail?

    2
    0 Votes
    2 Posts
    2k Views
    G
    Being in a Qt forum, I come up with a Qt base solution: @ QString filePath = QString("f/%1/%2/%3/%4/%5") .arg(dirHash1) .arg(dirHash2) .arg(dirHash3) .arg(dirHash4) .arg(fileName); QFileInfo fi(filePath); QDir dir = fi.absoluteDir(); if(!dir.exists()) dir.mkpath(fi.absoluteDirPath()); QFile file(filePath); @
  • Error handling (try catch)

    2
    0 Votes
    2 Posts
    3k Views
    ZlatomirZ
    The access violation error isn't thrown (exceptions are thrown not errors) - it occurs when you access memory that you don't own. Anyway you can initialize your pointers with 0 (null pointer) and then first check for 0 and only then call a member-function (to be a little more safer you can assign 0 to the pointer after you delete it then you detect the attempt to call function after the pointer is deleted)
  • 0 Votes
    7 Posts
    4k Views
    sierdzioS
    Sorry for being so talkative, but here are some further thoughts: Once a week is too rare to truly learn programming. I suggest you do more than is required - on your own. Will help you in later years of your study, too. After you get some basics from books/ tutors, get heavily onto building own applications. They don't have to be big or outstandingly functional, but will help you learn (file operations, regular expressions, databases, web interaction etc.).