Results 1 to 3 of 3

Thread: how to change size of window... stupid mistake

  1. #1
    Join Date
    Nov 2007
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default how to change size of window... stupid mistake

    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:n_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:n_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!!

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: how to change size of window... stupid mistake

    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:
    Qt Code:
    1. void C_Interfaz:n_ButtonConfig_released()
    2. {
    3. //C_Interfaz::ui.Interfaz->geometry.width(488, 266); //you are trying to use a class, instead of an object instance of that class.
    4.  
    5. C_Interfaz *InterfzObj = new C_Interfaz();
    6. QRect rect = InterfzObj->geometry();
    7. InterfzObj->setGeometry(rect.x(),rect.y(),488, 266);
    8.  
    9. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by high_flyer; 30th November 2007 at 15:06.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to change size of window... stupid mistake

    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?t...panding_dialog. In your case you should probably use the Minimum constraint.

Similar Threads

  1. Change shape of window / animate window
    By sabeesh in forum Qt Programming
    Replies: 3
    Last Post: 31st October 2007, 08:16
  2. Replies: 1
    Last Post: 9th February 2007, 09:41

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.