Skip to content

C++ Gurus

The forum for all discussions in C++ land.
1.3k Topics 8.6k Posts
  • Steps to debug dll in qt

    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • Displaying image

    5
    0 Votes
    5 Posts
    3k Views
    R
    [quote author="mjr_slim" date="1326462088"]As the others mention there are various ways to do this. This is my implementation... @ QPushButton *moveUpButton; ... moveUpButton = new QPushButton(QIcon("/path/to/jpeg/image",""); @ it will create a push button object with the jpeg image loaded inside the widget. More information can be found here http://developer.qt.nokia.com/doc/qt-4.8/qpushbutton.html#QPushButton-3[/quote] You can use a QPixmap as well . As a beginner , you must be interested why! That is implicit type conversion. It is there in docs.
  • How to sort and filter files based on names with numbers in them

    6
    0 Votes
    6 Posts
    6k Views
    S
    yah thats what I figured, we only needed to save the most recent update to update devices that havn't been up dated yet instead of redownloading an update. Instead I just made it so when we have a new update for ProgramA I added a filter to get everthing labled ProgramA* in the update folder and delete them, get rid of all of them before I download a newer update. Problem solved!
  • Objective C++ and Qt

    4
    0 Votes
    4 Posts
    5k Views
    G
    If you're using Qt Creator, then unfortunately the error pane doesn't show that useful error messages. It's just a "symbol(s) not found" and "collect2: ld returned exit status 1". You should go to the compilation pane then, the error messages there are more elaborate. In your special case here, if you use a Mac framework, you will have to add it to the LIBS variable. Some of them are added by Qt by default, some need manual addition.
  • QList and threads crash

    3
    0 Votes
    3 Posts
    4k Views
    F
    I'm using QMutexLocker locker(&m_mutex); // m_mutex is the member of the actual object in the only function which access the list. I think it should be enough. Do i need take other actions to guarantee safety? Edit: i've got it. :) Moved the mutex in a scope that every thread see the same, and then applying the lock mechanism. :) Thanks, for the feedback.
  • [Moved][Solved] Compiler header guard problem

    8
    0 Votes
    8 Posts
    5k Views
    G
    I moved this to the C++ Gurus forum, as it's nothing Qt related. You don't run into a header guard issue, those work as expected. And you don't get a compiler error that a variable is already declared, but the linker errors that a symbol is defined twice. This is caused by this line in your header file: @ QList<SVar *> varList; @ As the header is finally included in two .cpp files (via their "own" header files), the compiler generates two objects of the same name. As you did not put it into a namespace or the like they both reside as a global variable - and voilà: a name clash. Fortunately it's easy to circumvent this: Change Globals.h to @ extern QList<SVar *> varList; @ and add to one and only one source file (e.g. main.cpp) this line: @ QList<SVar *> varList; @ The change to the header file makes the variable just a declaration, so that the compiler just knows that there is a global variable of the name varList somewhere. And as you acutally need a physical incarnation of the variable, you will have to add it to some source file. Which source file doesn't matter, but main.cpp is a good candidate for such things.
  • Advice about sharing class members

    10
    0 Votes
    10 Posts
    4k Views
    D
    Don't worry. Finally I created a QWidget derived class for each struct I wanted to represent (separating the previous StructEditor class) and a Collection class for each struct (separating the previous StructManager class). Then I connect the Collection classes with the QWidget classes (the UI representation) using signals/slots!. By this way I kept encapsulation without repeating code, and also the UI is separated from data (something like MVC). Greetings!
  • Splash screen

    4
    0 Votes
    4 Posts
    4k Views
    R
    Okay, so you have two options for to show the preparations and status. One is Splash Screen Widget that i mentioned before. Other is "QProgressDialog":http://developer.qt.nokia.com/doc/qt-4.8/QProgressDialog.html . One easiest way of doing this verification, then shoing your mainwindow with the Qt Creator is using the "QStackedWidget":http://developer.qt.nokia.com/doc/qt-4.8/qstackedwidget.html Other ways are obvious, like a dialog box appears asks for authentication, and according to the result, show or hide something on your main window. Could be done in many ways. How ever, i feel like you can inspire something from this "example":http://developer.qt.nokia.com/doc/qt-4.7/network-network-chat.html#id-af7a94ea-06a9-47c5-a4cd-6a4ae2d1e12c or "this ":http://developer.qt.nokia.com/doc/qt-4.7/network-fortuneclient.html#id-e1394f8e-04d4-46b9-887d-e07cf2fe68fe
  • What can we do with QBitArray?

    9
    0 Votes
    9 Posts
    7k Views
    G
    [quote author="ibingow" date="1325211343"] In fact, i am writing a program to parse the swf file. Some flash information like width and height are stored in several bits, not bytes.[/quote] So QBitArray is cumbersome to use in the first place here. You would have to construct the bit array from a bunch of bytes into something that doesn't take bytes in its constructor or methods. All that only to split the array afterwards and reconstructing your data. Looks more than awkward to me. I would read the bytes as such and get the bits or bitfields by using masks.
  • 0 Votes
    13 Posts
    11k Views
    S
    Thanks, Lukas. Volker already kindly provided the link and I am studying the whole FAQ. Better yet, I have sent an e-mail to volunteer to translate in Turkish.
  • Wrapper design: advice need for classes inside Qt5

    3
    0 Votes
    3 Posts
    2k Views
    A
    #qt-labs and the developer@qt-project.org mailinglist also would be good places.
  • Advice: pure virtual method in base class implemented in subclass

    5
    0 Votes
    5 Posts
    5k Views
    F
    [quote author="Volker" date="1324298291"]Calling virtuals in constructors: Not only it's dangerous, it plain doesn't work. [/quote] Thanks, I know it is bad. In fact I'm going to change it. I simply did not realize from the compiling error that it was in my constructor path.
  • C++11 range-based for loop doesn't seem to be working?

    6
    0 Votes
    6 Posts
    5k Views
    M
    Aha! That explains it. Thanks :-)
  • Close() / write() was not declared in this scope

    7
    0 Votes
    7 Posts
    19k Views
    V
    Thank you. I was out of the office, so can not reply promptly. The problem solved. Brief description: I could not find ioctl.h. It was really stupid error – I was testing the application on Widows platform that is not proper for ioctl The error aroused during compilation as close() ( read(), write() ) is not defined. In Linux to use this in *.cpp mtio.h needs to be included.
  • Cross-compiling Qt, link order .so & .a &#63;

    4
    0 Votes
    4 Posts
    3k Views
    P
    Maybe this helps. Add the library by path. You will be sure that it's the library you wanna use: LIBS += /somepath/libMyQtLib.so or try editing as AlterX probably suggested: LD_LIBRARY_PATH LD_RUNTIME_PATH
  • HTTP Query related

    4
    0 Votes
    4 Posts
    2k Views
    L
    The following "wiki article about downloading a file/content over HTTP":http://developer.qt.nokia.com/wiki/Download_Data_from_URL might be useful to solve your issue. The code snippet is not related to UI.
  • [Solved][Moved] Can not use ioctl in Qt 4

    7
    0 Votes
    7 Posts
    7k Views
    V
    Thank you. It's ok now.
  • Using QT with keyboard but without benefit of the mouse

    Locked
    2
    0 Votes
    2 Posts
    2k Views
    EddyE
    Please don't post the same question twice in defferent subforums. I'm closing this one. Continue on "this thread":https://developer.qt.nokia.com/forums/viewthread/12092/ please.
  • 0 Votes
    3 Posts
    3k Views
    G
    Hi, first of all, I moved it to the C++ forum, as it's more a generic problem then a Qt problem. I assume, you cxall the function with a string and then (outside the function) the string is not changed, right? Zhis comes due to the fact, that cou call the function with a copy of your string you want to change. If you want to modify the original string, you need a pointer or a reference: @ void Convert(QString& givenphonenum) { } @ The second problem you have, is that the string might be shorter then 100 chars. Try out the following: @ void Convert(QString& givenphonenum) { for (int i = 0; i < givenphonenum.length(); i++) { } } @
  • 0 Votes
    11 Posts
    7k Views
    S
    Ok, thanks to help.