PDA

View Full Version : Class 'QWidge't has no member named 'setSize'



Omicron
3rd April 2011, 15:23
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:



createSLabel();


This is the createSLabel function:



void MainWindow::createLLabel()
{
localLabel = new QLabel(tr("Local view"), centralWidget);
localLabel->setAlignment(Qt::AlignCenter);
}


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?

stampede
3rd April 2011, 15:28
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.

Omicron
3rd April 2011, 16:08
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 :p But createLLabel is basically the same with a different label:



void MainWindow::createLLabel()
{
localLabel = new QLabel(tr("Local view"), centralWidget);
localLabel->setAlignment(Qt::AlignCenter);
}

stampede
3rd April 2011, 16:11
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).

tomhanks
3rd April 2011, 16:23
i think you should use resize() method

Omicron
3rd April 2011, 16:48
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 :D



void MainWindow::createSLabel()
{
serverLabel = new QLabel(tr("FTP server view"), centralWidget);
serverLabel->setAlignment(Qt::AlignCenter);
}


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!!! :eek:
Sorry for using up your time :(