Results 1 to 2 of 2

Thread: Difficulty in making a window

  1. #1
    Join Date
    Jul 2014
    Posts
    95
    Thanks
    67

    Default Difficulty in making a window

    Hello
    The following code will not run? Why?
    Please correct.
    thanks.
    Qt Code:
    1. #ifndef E_H
    2. #define E_H
    3. #include <QWidget>
    4. #include <QPaintEvent>
    5. class window:public QWidget
    6. {public:
    7. window(QWidget* parent=0);
    8.  
    9. };
    10. #endif // E_H
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. #include <QtWidgets>
    2. #include "window.h"
    3. window::window(QWidget *parent): QWidget(parent)
    4. {
    5. resize(200, 200);
    6. setWindowTitle("Window");
    7. }
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. #include <QWidget>
    2. #include "window.h"
    3. int main(int argc, char *argv[])
    4. {
    5. QApplication app(argc, argv);
    6. window win;
    7. win.show();
    8. return app.exec();
    9. }
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. QT=widgets
    2. SOURCES += \
    3. main.cpp \
    4. window.cpp
    5.  
    6. HEADERS += \
    7. window.h
    To copy to clipboard, switch view to plain text mode 
    Untitled1.jpg

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Difficulty in making a window

    Missing include for QApplication.

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    rezas1000 (31st August 2014)

Similar Threads

  1. Making a mouse click event close the window
    By Momergil in forum Qt Programming
    Replies: 2
    Last Post: 17th February 2013, 19:58
  2. making Transparent window inactive on loose focus
    By Beena in forum Qt Programming
    Replies: 0
    Last Post: 17th November 2010, 07:01
  3. Making the whole window/form scrollable
    By ike in forum Qt Tools
    Replies: 2
    Last Post: 6th October 2008, 20:24
  4. making an application window non resizable
    By aegis in forum Qt Programming
    Replies: 16
    Last Post: 13th May 2007, 20:14
  5. Making some part of window transparent
    By yogeshm02 in forum Qt Programming
    Replies: 1
    Last Post: 27th March 2006, 21:36

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.