Results 1 to 2 of 2

Thread: Opening a new window

  1. #1
    Join Date
    Feb 2009
    Posts
    13
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Smile Opening a new window

    Hi there, folks!!

    I have a bit of a problem here with being able to declare an object from a class derived from a UI file designed with Qt Designer, in other words:

    in adddialog.h,

    Qt Code:
    1. #ifndef ADDDIALOG_H
    2. #define ADDDIALOG_H
    3. #include "ui_adddialog.h"
    4.  
    5. class adddialog : public QDialog, private Ui::AddDLG {
    6. Q_OBJECT
    7. public:
    8. adddialog ();
    9. };
    10. #endif // ADDDIALOG_H
    To copy to clipboard, switch view to plain text mode 

    in adddialog.cpp,

    Qt Code:
    1. #include "adddialog.h"
    2.  
    3. adddialog::adddialog() {
    4. setupUi(this);
    5. }
    To copy to clipboard, switch view to plain text mode 

    and in the implementation of the main window,

    Qt Code:
    1. #include "adddialog.h"
    2. ...
    3. void mainwindow::adddialog() {
    4. adddialog add;
    5. add.show();
    6. }
    To copy to clipboard, switch view to plain text mode 

    void adddialog in the class mainwindow is a slot, later used to connect a button to it, and hence make an "Add Dialog" launch whenever the button is clicked.
    When I run this code I get the following errors:

    "expected ; before 'add' "
    "statement cannot resolve address of overloaded function"
    " 'add' was not declared in this scope"

    What am I doing wrong??? As usual sample code would be very appreaciated.

    Thanks in advance

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Opening a new window

    Rename function mainwindow::adddialog(), it conflicts with the class of the same name. Furthermore, the dialog goes immediately out of scope according to normal C++ rules. You should either use blocking exec() or allocate it on the heap, depending on whether you want it to be model and modeless.
    J-P Nurmi

Similar Threads

  1. How to set Qt window transparent?
    By montylee in forum Qt Programming
    Replies: 17
    Last Post: 24th December 2013, 20:11
  2. QMain Window Problem
    By maveric in forum Qt Programming
    Replies: 1
    Last Post: 24th May 2008, 15:51
  3. Set a window as child at runtime
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 26th November 2007, 09:30
  4. Change shape of window / animate window
    By sabeesh in forum Qt Programming
    Replies: 3
    Last Post: 31st October 2007, 08:16
  5. move parent window to the front.
    By hvengel in forum Qt Programming
    Replies: 4
    Last Post: 2nd February 2007, 08: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
  •  
Qt is a trademark of The Qt Company.