Results 1 to 1 of 1

Thread: qt3 using cmake simple application question (problem solved)

  1. #1
    Join Date
    Sep 2008
    Posts
    23
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Question qt3 using cmake simple application question (problem solved)

    Problem solved. It should be
    class WindowBase : public QMainWindow
    instead of
    class WindowBase : private QMainWindow
    Thanks to CMake mail list.

    hi, there

    I need to write an application in qt3 with cmake and here is my very beginning:
    just display a mainwindow and nothing else (the mainwindow is produced
    by qt designer windowbase.ui ) I have my own reason to do it in qt3
    not in qt4 (for thumbnail view).

    During compiling, I get:
    -----------------------------
    windowbase.h

    class WindowBase : private QMainWindow }{...}
    -----------------------------

    -----------------------------
    windowbase.cxx
    -----------------------------

    I manually create the following files:

    window.h

    Qt Code:
    1. #ifndef WINDOW_H
    2. #define WINDOW_H
    3. #include "windowbase.h"
    4.  
    5. class Window : private WindowBase{
    6. public: //nothing else
    7. public slots: //nothing else
    8. };
    9. #endif
    To copy to clipboard, switch view to plain text mode 

    window.cpp
    Qt Code:
    1. #include "window.h"
    2. // nothing else
    To copy to clipboard, switch view to plain text mode 

    main.cpp
    Qt Code:
    1. #ifdef HAVE_CONFIG_H
    2. #include <config.h>
    3. #endif
    4.  
    5. #include <stdio.h>
    6. #include <stdlib.h>
    7. #include <qapplication.h>
    8. #include "window.h"
    9. #include <qmainwindow.h>
    10.  
    11. int main(int argc, char *argv[])
    12. {
    13. QApplication myApp(argc,argv);
    14. Window * mypWindow = new Window();
    15. myApp.setMainWidget(mypWindow); //error here, line 23
    16. mypWindow->show();
    17. return myApp.exec();
    18. return EXIT_SUCCESS;
    19. }
    To copy to clipboard, switch view to plain text mode 

    The CMakeLists.txt is as following (I highly suspect something wrong
    here, I stitched the script but not sure what I am doing. And I can't
    find any example related to qt3 + cmake + ui anywhere)

    Qt Code:
    1. PROJECT(study3)
    2.  
    3. SET(CMAKE_VERBOSE_MAKEFILE ON)
    4. ADD_DEFINITIONS(-Wall -O2)
    5.  
    6. FIND_PACKAGE(Qt3 REQUIRED)
    7. ADD_DEFINITIONS(${QT_DEFINITIONS})
    8.  
    9. INCLUDE_DIRECTORIES(
    10. ${CMAKE_BINARY_DIR}
    11. ${QT_INCLUDE_DIR}
    12. ${QT_INCLUDE_PATH}
    13. )
    14.  
    15. SET(STUDY3_UI_SRC
    16. windowbase.ui
    17. )
    18.  
    19. SET(STUDY3_SOURCES
    20. window.cpp main.cpp
    21. )
    22.  
    23. QT_WRAP_UI(study3 STUDY3_UI_H STUDY3_UI_CPP ${STUDY3_UI_SRC})
    24. QT_WRAP_CPP(study3 STUDY3_UI_CPP ${STUDY3_UI_H})
    25.  
    26. # I am not sure where and how or if I need to put "moc" somewhere
    27.  
    28. INCLUDE_DIRECTORIES(
    29. ${CMAKE_SOURCE_DIR}
    30. ${CMAKE_CURRENT_SOURCE_DIR}
    31. )
    32.  
    33. ADD_EXECUTABLE(study3
    34. ${STUDY3_SOURCES}
    35. ${STUDY3_UI_CPP}
    36. )
    37.  
    38. TARGET_LINK_LIBRARIES(study3 ${QT_LIBRARIES} png jpeg)
    To copy to clipboard, switch view to plain text mode 

    Here is the error message I got during compile:

    Qt Code:
    1. /study3/main.cpp:23: error: 'QWidget' is an inaccessible base of 'Window'
    2. /usr/share/qt3/include/qmainwindow.h:98: error: 'virtual void
    3. QMainWindow::show()' is inaccessible
    4. /study3/main.cpp:24: error: within this context
    5. /study3/main.cpp:24: error: 'QMainWindow' is not an accessible base of 'Window'
    To copy to clipboard, switch view to plain text mode 

    But, if I change the line 23 into

    Qt Code:
    1. WindowBase * mypWindow = new WindowBase();
    To copy to clipboard, switch view to plain text mode 

    then the program can compile and runs fine.

    The Window class inherits from WindowBase and I am suppose to do my
    own stuff there (in current case I do nothing). What's wrong with my
    code? Thanks for your comments.

    zl2k
    Last edited by zl2k; 2nd September 2008 at 05:26.

Similar Threads

  1. QTextEdit simple question
    By Marcopolo in forum Qt Tools
    Replies: 4
    Last Post: 11th October 2007, 00:01
  2. Two question about create an application.
    By Kenneth in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 19th March 2007, 22:21
  3. Replies: 2
    Last Post: 12th January 2007, 11:19
  4. simple thread layout question
    By mhoover in forum Qt Programming
    Replies: 1
    Last Post: 12th August 2006, 11:02
  5. Simple Question on Variable initialization
    By Naveen in forum Qt Programming
    Replies: 3
    Last Post: 17th March 2006, 11:01

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.