Results 1 to 7 of 7

Thread: Multi-Window Application

  1. #1
    Join Date
    Oct 2012
    Posts
    4
    Thanks
    1
    Platforms
    Unix/X11

    Default Multi-Window Application

    Hi!

    I've been tinkering around with this for a couple days, and errors have come and gone, but still I haven't successfully compiled this. I figure I'm missing something very simple, but haven't tracked it down yet.

    The Scenario:
    I have a main window that works just fine, a simulator. From this I've connected a push button to a function in a source file, MUstarter.cpp, that will act as a copy of main to start the other window. The reason: I want to keep the new window's code isolated so I can deploy it as a separate project later. I have a feeling the main issue is with the header file for the new window, but I'm not sure.

    The code:
    MUstarter.cpp -> called from the generator window, should act how main usually does.
    Qt Code:
    1. #include <QtGui/QApplication>
    2.  
    3. #include "MobileUnit.h"
    4. #include "ui_MobileUnit.h"
    5.  
    6. void MUStarter()
    7. {
    8. MobileUnit MU;
    9. MU.show();
    10. MU.setWindowTitle(
    11. QApplication::translate("MobileUnit", "Mobile Unit"));
    12. }
    To copy to clipboard, switch view to plain text mode 
    MobileUnit.cpp -> define any widget functionality of the new ui.
    Qt Code:
    1. #include "MobileUnit.h"
    2. #include "ui_MobileUnit.h"
    3.  
    4. #include <QWidget>
    5.  
    6. MobileUnit::MobileUnit(QWidget *parent) :
    7. QWidget(parent),
    8. MU(new Mu::MobileUnit)
    9. {
    10. MU->setupUi(this);
    11. }
    12.  
    13. MobileUnit::~MobileUnit()
    14. {
    15. delete MU;
    16. }
    To copy to clipboard, switch view to plain text mode 
    MobileUnit.h -> class definitions
    Qt Code:
    1. #ifndef MOBILEUNIT_H
    2. #define MOBILEUNIT_H
    3.  
    4. #include <QWidget>
    5.  
    6. namespace Mu {
    7. class MobileUnit;
    8. }
    9.  
    10. class MobileUnit: public QWidget
    11. {
    12. Q_OBJECT
    13.  
    14. public:
    15. explicit MobileUnit(QWidget *parent = 0);
    16. ~MobileUnit();
    17.  
    18. private:
    19. Mu::MobileUnit *MU;
    20. // void MUStarter();
    21. };
    22.  
    23. #endif // MOBILEUNIT_H
    To copy to clipboard, switch view to plain text mode 
    Thanks in advance for any help!

  2. #2
    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: Multi-Window Application

    What errors are you getting?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Oct 2012
    Posts
    4
    Thanks
    1
    Platforms
    Unix/X11

    Default Re: Multi-Window Application

    Sorry, that would probably help!

    ../SRLmainApp/MobileUnit/MobileUnit.cpp: In constructor 'MobileUnit::MobileUnit(QWidget*)':
    ../SRLmainApp/MobileUnit/MobileUnit.cpp:9:16: error: invalid use of incomplete type 'struct Mu::MobileUnit'
    ../SRLmainApp/MobileUnit/MobileUnit.h:7:7: error: forward declaration of 'struct Mu::MobileUnit'
    ../SRLmainApp/MobileUnit/MobileUnit.cpp:11:7: error: invalid use of incomplete type 'struct Mu::MobileUnit'
    ../SRLmainApp/MobileUnit/MobileUnit.h:7:7: error: forward declaration of 'struct Mu::MobileUnit'
    ../SRLmainApp/MobileUnit/MobileUnit.cpp: In destructor 'virtual MobileUnit::~MobileUnit()':
    ../SRLmainApp/MobileUnit/MobileUnit.cpp:16:12: warning: possible problem detected in invocation of delete operator: [enabled by default]
    ../SRLmainApp/MobileUnit/MobileUnit.cpp:16:12: warning: invalid use of incomplete type 'struct Mu::MobileUnit' [enabled by default]
    ../SRLmainApp/MobileUnit/MobileUnit.h:7:7: warning: forward declaration of 'struct Mu::MobileUnit' [enabled by default]
    ../SRLmainApp/MobileUnit/MobileUnit.cpp:16:12: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined
    make: *** [MobileUnit.o] Error 1

    This is about the worst it's been, but regardless, I still don't know why I'd be getting all these errors.

  4. #4
    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: Multi-Window Application

    Which file defines the Mu::MobileUnit class? Shouldn't it be Ui::MobileUnit?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Oct 2012
    Posts
    4
    Thanks
    1
    Platforms
    Unix/X11

    Default Re: Multi-Window Application

    Maybe I'm wrong - I thought to differentiate between the two sources I should define a new namespace for this gui. The 'Mu' namespace was defined in the header file, 'MobileUnit.h'.

    Should I stick with the Ui namespace, or does it matter? I assumed it would be arbitrary, but maybe the .ui forms are closely linked to that Ui namespace... ?

  6. #6
    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: Multi-Window Application

    Quote Originally Posted by bernard View Post
    Maybe I'm wrong - I thought to differentiate between the two sources I should define a new namespace for this gui. The 'Mu' namespace was defined in the header file, 'MobileUnit.h'.
    You defined the namespace but you didn't put the MobileUnit class in it. There is a difference between MobileUnit and MU::MobileUnit, they are two totally separate entities.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. The following user says thank you to wysota for this useful post:

    bernard (30th October 2012)

  8. #7
    Join Date
    Oct 2012
    Posts
    4
    Thanks
    1
    Platforms
    Unix/X11

    Default Re: Multi-Window Application

    That solved it! Another problem I was having was that using Mu instead of Ui caused some contradictions with the Ui namespace in ui_MobileUnit.h built elsewhere (or at least that's my guess).

    Thanks for the help!

Similar Threads

  1. Multi Window Application in QT
    By GopakumarG in forum Qt Programming
    Replies: 2
    Last Post: 20th April 2011, 06:42
  2. Replies: 0
    Last Post: 18th November 2010, 16:48
  3. A multi-windowed application with Qt
    By ouekah in forum Newbie
    Replies: 4
    Last Post: 13th April 2010, 15:44
  4. Multi-window document structure
    By JariV in forum Newbie
    Replies: 2
    Last Post: 16th February 2009, 20:42
  5. Multi Window Application in QT/C++
    By pshah.mumbai in forum Newbie
    Replies: 8
    Last Post: 8th July 2008, 17:21

Tags for this Thread

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.