Results 1 to 6 of 6

Thread: Class 'QWidge't has no member named 'setSize'

  1. #1
    Join Date
    Apr 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Question Class 'QWidge't has no member named 'setSize'

    I'm creating an application using Qt 4.7.1 and MinGW. I recently re-arranged my code into different functions, but when I try to compile my code with 'mingw32-make' this happens:

    mainwindow.cpp:14: error: 'class QWidget' has no member named 'setSize'

    In mainwindow.cpp on line 14 I have:

    Qt Code:
    1. createSLabel();
    To copy to clipboard, switch view to plain text mode 

    This is the createSLabel function:

    Qt Code:
    1. void MainWindow::createLLabel()
    2. {
    3. localLabel = new QLabel(tr("Local view"), centralWidget);
    4. localLabel->setAlignment(Qt::AlignCenter);
    5. }
    To copy to clipboard, switch view to plain text mode 

    I also have another function that's called that has exactly the same code as this but with a different QLabel, but no errors occur for that. I don't see what's wrong with my code. Why is this happening?

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Class 'QWidge't has no member named 'setSize'

    This is the createSLabel function
    For me this one looks more like createLLabel Is this a typo, or you've just pasted wrong method ?
    There should be no errors in posted code.

  3. #3
    Join Date
    Apr 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Class 'QWidge't has no member named 'setSize'

    Quote Originally Posted by stampede View Post
    For me this one looks more like createLLabel Is this a typo, or you've just pasted wrong method ?
    There should be no errors in posted code.
    I pasted the wrong one, thanks for pointing it out But createLLabel is basically the same with a different label:

    Qt Code:
    1. void MainWindow::createLLabel()
    2. {
    3. localLabel = new QLabel(tr("Local view"), centralWidget);
    4. localLabel->setAlignment(Qt::AlignCenter);
    5. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Class 'QWidge't has no member named 'setSize'

    And you've pasted createLLabel again
    Maybe post the whole file, you should have setSize call for a widget object somewhere in the code (btw. should be resize according to docs).

  5. #5
    Join Date
    Mar 2011
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default Re: Class 'QWidge't has no member named 'setSize'

    i think you should use resize() method

  6. #6
    Join Date
    Apr 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Class 'QWidge't has no member named 'setSize'

    Quote Originally Posted by stampede View Post
    And you've pasted createLLabel again
    Maybe post the whole file, you should have setSize call for a widget object somewhere in the code (btw. should be resize according to docs).
    Hah, I think I didn't press Ctrl+C hard enough

    Qt Code:
    1. void MainWindow::createSLabel()
    2. {
    3. serverLabel = new QLabel(tr("FTP server view"), centralWidget);
    4. serverLabel->setAlignment(Qt::AlignCenter);
    5. }
    To copy to clipboard, switch view to plain text mode 

    I don't have any call to setSize anywhere in that file. It said line 14, so isn't the problem with that function? It might not be because the other function didn't cause an error. I have called resize() for the main window at the beginning, but that's not the cause of the problem because it compiled fine earlier. I'm going to try commenting out the suspect lines to find the culprit. I'll post back on what happens


    Added after 8 minutes:


    I AM SO STUPID!!! I had 2 folders of the project and I was editing the code of one, and trying to compile the other!!!
    Sorry for using up your time
    Last edited by Omicron; 3rd April 2011 at 17:48.

Similar Threads

  1. accessing static member variables of one class in another class
    By jasonknight in forum General Programming
    Replies: 5
    Last Post: 6th September 2010, 15:53
  2. Replies: 4
    Last Post: 29th May 2010, 13:56
  3. A class member has ran away?!
    By MIH1406 in forum Newbie
    Replies: 4
    Last Post: 25th August 2009, 00:21
  4. Replies: 2
    Last Post: 29th June 2009, 07:09
  5. Replies: 5
    Last Post: 14th July 2006, 23:42

Tags for this Thread

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.