Results 1 to 12 of 12

Thread: GUI compile problem

  1. #1
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default GUI compile problem

    I should be able to see why this is happening, but then again, I'm a newbie.

    Compiler says 'actionQuit' was not declared in this scope.
    Here is part of the mainwindow.cpp:

    Qt Code:
    1. #include <QtGui>
    2. #include "mainwindow.h"
    3. #include "ui_mainwindow.h"
    4.  
    5. MainWindow::MainWindow(QWidget *parent)
    6. : QMainWindow(parent), ui(new Ui::MainWindow)
    7. {
    8. ui->setupUi(this);
    9. setupActions();
    10. mStatLabel = new QLabel;
    11. statusBar()->addPermanentWidget(mStatLabel);
    12. connect(textEdit, SIGNAL(textChanged()), this, SLOT(updateStats()));
    13. updateStats();
    14. }
    15.  
    16. void MainWindow::setupActions()
    17. {
    18. connect(actionQuit, SIGNAL(triggered(bool)),
    19. qApp, SLOT(quit()));
    To copy to clipboard, switch view to plain text mode 

    I have checked to be sure the menu item is indeed actionQuit.
    So what am I missing?

  2. #2
    Join Date
    Apr 2009
    Posts
    46
    Thanks
    4
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: GUI compile problem

    If you are using designer then actionQuit you call through ui.

    Qt Code:
    1. connect(ui->actionQuit, SIGNAL(triggered()), qApp, SLOT(quit()));
    To copy to clipboard, switch view to plain text mode 

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

    waynew (17th October 2009)

  4. #3
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: GUI compile problem

    Thanks RSX, that did it.

    Just trying to get used to things in Qt.

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

    Default Re: GUI compile problem

    Quote Originally Posted by waynew View Post
    Just trying to get used to things in Qt.
    Your problem had nothing to do with Qt, it was strictly C++ related.
    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.


  6. #5
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: GUI compile problem

    Indeed, if you want to refer to actionQuit as exactly that instead of ui->actionQuit, then you need to use multiple inheritance. An example is here.

  7. #6
    Join Date
    Dec 2008
    Location
    Qt Reference Documentation
    Posts
    62
    Thanks
    25
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: GUI compile problem

    Quote Originally Posted by RSX View Post
    If you are using designer then actionQuit you call through ui.

    Qt Code:
    1. connect(ui->actionQuit, SIGNAL(triggered()), qApp, SLOT(quit()));
    To copy to clipboard, switch view to plain text mode 
    shoudn't it be ui.actionQuit ?

  8. #7
    Join Date
    Aug 2008
    Location
    Algarve, Portugal
    Posts
    288
    Thanks
    23
    Thanked 32 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: GUI compile problem

    It's
    Qt Code:
    1. ui.actionQuit
    To copy to clipboard, switch view to plain text mode 
    if ui was declared on the stack, and it's
    Qt Code:
    1. ui->actionQuit
    To copy to clipboard, switch view to plain text mode 
    if ui was declare in heap, like a pointer

  9. #8
    Join Date
    Dec 2008
    Location
    Qt Reference Documentation
    Posts
    62
    Thanks
    25
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: GUI compile problem

    Yes, but since it is auto-generated by Qt's UIC, then it must always be on the stack, right?

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

    Default Re: GUI compile problem

    No, why...?
    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.


  11. #10
    Join Date
    Aug 2008
    Location
    Algarve, Portugal
    Posts
    288
    Thanks
    23
    Thanked 32 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: GUI compile problem

    I just check in one project, it's in the heap

    Qt Code:
    1. private:
    2. Ui::area_dlg *m_ui;
    To copy to clipboard, switch view to plain text mode 

  12. #11
    Join Date
    Dec 2008
    Location
    Qt Reference Documentation
    Posts
    62
    Thanks
    25
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: GUI compile problem

    I see now, at first I thought that UIC always generates ui as an object rather than a pointer, but then I realized that it's the IDE that generated this, not UIC.

    Sorry if I wasted your time

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

    Default Re: GUI compile problem

    UIC generates classes, not objects.
    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.


Similar Threads

  1. problem when trying to compile it.
    By cbarmpar in forum Qwt
    Replies: 1
    Last Post: 16th January 2009, 20:16
  2. Problem compile example in windows
    By walito in forum Newbie
    Replies: 3
    Last Post: 10th December 2008, 21:41
  3. Steps in solving a programming problem?
    By triperzonak in forum General Programming
    Replies: 8
    Last Post: 5th August 2008, 08:47
  4. Qwt plot problem on compile
    By sincnarf in forum Qwt
    Replies: 2
    Last Post: 14th October 2007, 11:36
  5. Qt-4.2.2 qmake won't compile under visual studio 2005 on vista
    By moowy in forum Installation and Deployment
    Replies: 7
    Last Post: 13th January 2007, 21:06

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.