Skip to content

C++ Gurus

The forum for all discussions in C++ land.
1.3k Topics 8.6k Posts
  • 0 Votes
    7 Posts
    4k Views
    M
    You don't know much about signals and slots, do you? ;) Knowing that stuff is probably one of the most important things you'll need to know to do any substantive work with Qt. I'd insist upon you going through the "documentation":/doc/qt-4.8/signalsandslots.html that covers it. (It's stuff you have to know cold.) But, in short (though I'm reluctant to spoon feed it...) you would define a signal such as: @ signals: void mySignal(QString); @ (you don't have to write the implementation of this. It will be autogenerated.) and to use it in your code you use: @ emit mySignal("Whatever text I want to send."); @ That signal would ideally be connected to a slot with a compatible signature: @ connect(sourcePointer, SIGNAL(mySignal(QString)), destPointer, SLOT(someSlot(QString))); @ Edit to add: Since the code for the body of the signal is generated by MOC, the return type of the signal is void. The string you want to pass in is a parameter because the MOC-generated code knows how to take that value passed in as a parameter and poke it into the corresponding parameter in the connected slot.
  • Doubt about const member and containers

    4
    0 Votes
    4 Posts
    2k Views
    K
    Sry I didn't consider the case of modifying the data inside the class.
  • 0 Votes
    2 Posts
    2k Views
    M
    A few things I notice offhand... It's probably complaining about line 14 above, which uses backslashes instead of slashes. qmake and the build chain are notoriously picky about having spaces in the path names You have empty hyphens ending lines 14, 20, and 23 Also make sure there are no trailing spaces after your line-ending backslashes.
  • 0 Votes
    2 Posts
    14k Views
    ZlatomirZ
    That must happen because the default constructor of QObject is private, so define an constructor for your class to pass a QObject* parent to the QObject constructor @ class tCamera : public QObject { Q_OBJECT public: tCamera(QObject* parent = 0); //pass parent to QObject's c-tor in the definition of your c-tor //... @ Also you should make sure to disable the copy for your class using "q_disable_copy or private copy c-tor and assignment operator":http://qt-project.org/doc/qt-4.8/qobject.html#Q_DISABLE_COPY
  • Qt method swizzling

    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • Problem with updating itk image in Qt user interface

    4
    0 Votes
    4 Posts
    3k Views
    M
    Hi everyone Actually I'm working with ITK and I want to know how you did to integrate C++ with QT. I just want to know how it works because I'm new on it. I'm working on image co-registration using ITK and I want to display the result on a GUI with QT but I don't know how to proceed! any help?? Massinissa
  • 0 Votes
    5 Posts
    5k Views
    L
    I assume this is no problem of QLibrary but of the DLL itself. As I'm not programming on Windows systems regularly I'm not sure about that, but I assume that DllMain may be not called. If the function you are using is relying on an index that is initialized in DllMain it may be possible that using that index to write somewhere in the memory might lead to very interesting behaviour. Maybe you need to call DllMain manually or possibly - as you've got the library developer at hand - the DLL could provide an other entry point that initializes all necessary values? As said before: I'm not sure if DllMain should be called when using QLibrary!
  • 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
    5k 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
    5k 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
    3k 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
    6k Views
    A
    I think it's the same one I stumbled upon. ;-)
  • How can I interrupt a function?

    15
    0 Votes
    15 Posts
    14k 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.