PDA

View Full Version : how to change size of window... stupid mistake



Sergio_Almonte
30th November 2007, 14:14
heello people!

I´m trying to make an aplication with a window with 2 "areas". when the aplication is loaded, I want to show only the "normal" area, and when the button "config" is pressed, I want to make big the window, so it shows the controls of the second area. I have read the documentation and I know that width() function or resize() function does it,

void C_Interfaz::on_ButtonConfig_released()
{
C_Interfaz::ui.Interfaz->geometry.width(488, 266);
}

but I´m quite new in OOP and then when I try to implement this, come an error:

interfaz.cpp: In member function 'void C_Interfaz::on_ButtonConfig_released()':

interfaz.cpp:38: error: invalid use of 'class Ui::Interfaz'

my main function is like this:

int main(int argc, char *argv[])
{
QApplication a(argc, argv);

C_Interfaz Interfaz;
Interfaz.show();

return a.exec();
}

and my class constructor is:

class C_Interfaz: public QWidget
{
Q_OBJECT

public:
C_Interfaz
(QWidget *parent=0,
Qt::WFlags flags=0);
~C_Interfaz();
Ui::Interfaz ui;

private slots:

void on_ButtonConfig_released();
};

could you help me to find my mistake??

thanks!!

high_flyer
30th November 2007, 14:35
Are you new to OOP, or to programming?
At any rate, it looks you do not understand the difference between a class and an object.
You should start by reading and understanding these (and other) basic pricipals before you start programming "real" applications.

To your error:

void C_Interfaz:n_ButtonConfig_released()
{
//C_Interfaz::ui.Interfaz->geometry.width(488, 266); //you are trying to use a class, instead of an object instance of that class.

C_Interfaz *InterfzObj = new C_Interfaz();
QRect rect = InterfzObj->geometry();
InterfzObj->setGeometry(rect.x(),rect.y(),488, 266);

}

wysota
30th November 2007, 15:00
Apart from what Daniel already said, I can add that this is a wrong approach (not Daniel's, the thread autor's). Take a look at this article, maybe it gives you some hints:
http://wiki.qtcentre.org/index.php?title=Expanding_dialog. In your case you should probably use the Minimum constraint.