Results 1 to 3 of 3

Thread: Are there C/C++ commands which don't work with Qt?

  1. #1
    Join Date
    Jan 2006
    Posts
    46
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Are there C/C++ commands which don't work with Qt?

    This is either a very silly mistake which is staring me in the face,
    or something weird...


    in maze.h:

    class MazeField : public QWidget {

    Q_OBJECT
    public:
    MazeField( QWidget *parent=0, const char *name=0 );

    QSizePolicy sizePolicy() const;

    (...)
    int ** Log;
    void MazeField::intialiseLog();
    (...)
    };


    in maze.cpp:

    int NUMBER_OF_COLUMNS = 4;
    int NUMBER_OF_ROWS = 10;

    (...)

    // Used at initialisation
    void MazeField::intialiseLog() {
    Log = (int **) calloc ((NUMBER_OF_COLUMNS + 1), sizeof(int *));
    for (int col = 0; col < NUMBER_OF_COLUMNS; col++) {
    Log[col] = (int *) calloc ((NUMBER_OF_ROWS + 2), sizeof(int));
    }
    Log[0][0] = 3;
    Log[0][5] = 5;
    for (int row = 0; row < NUMBER_OF_ROWS; row++) {
    for (int col = 1; col < NUMBER_OF_COLUMNS; col++) {
    cout << Log[col][row];
    }
    cout << endl;
    }
    exit(0);
    }

    It outputs :

    000
    000
    000
    000
    000
    000
    000
    000
    000
    000

    And I've been unable to make it output any number except zeros...

    Mariane
    Last edited by Mariane; 30th January 2006 at 22:24. Reason: The indentation disappeared (tabs)

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Are there C/C++ commands which don't work with Qt?

    Quote Originally Posted by Mariane
    for (int col = 1; col < NUMBER_OF_COLUMNS; col++) {
    Try with "col = 0".

    PS. Next time, please use [ c o d e ] tags.

  3. #3
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Are there C/C++ commands which don't work with Qt?

    Talking about C++ aren't you??? So why do you use calloc instead of new ??? it produces hardly readable code and has no avantages in your case since you initialize all the items of your array!
    Current Qt projects : QCodeEdit, RotiDeCode

Similar Threads

  1. Qt4 : QPainter::setRedirected doesn't work
    By Ankitha Varsha in forum Qt Programming
    Replies: 2
    Last Post: 20th June 2008, 17:52
  2. QActions don't work with menubar hidden
    By Pepe in forum Qt Programming
    Replies: 1
    Last Post: 16th August 2007, 01:04
  3. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21
  4. Change work area OS
    By pakulo in forum Qt Programming
    Replies: 15
    Last Post: 15th May 2007, 07:20
  5. how to corss compile for windows in Linux
    By safknw in forum Qt Programming
    Replies: 24
    Last Post: 13th May 2006, 05:23

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.