Results 1 to 5 of 5

Thread: port qt3 app to desinger 4 ui files

  1. #1
    Join Date
    Mar 2006
    Posts
    74
    Thanks
    1
    Qt products
    Qt3
    Platforms
    MacOS X Unix/X11 Windows

    Default port qt3 app to desinger 4 ui files

    I have converted the ui files for my app from designer 3 to designer 4. Now I am looking at the examples trying to figure what I need to do to use the files generated by uic 4. My qt 3 code is structured like this:

    mydialogbase.ui contains the MyDialogBase dialog. Then in mydialog.h I subclass the MyDialogBase object like this:

    Qt Code:
    1. #include "mydialogbase.h"
    2.  
    3. class MyDialog : public MyDialogBase
    4. {
    5. Q_OBJECT
    6.  
    7. public:
    8.  
    9. MyDialog(QWidget *parent = 0);
    10. ~MyDialog();
    11.  
    12. ....
    13.  
    14. };
    To copy to clipboard, switch view to plain text mode 

    In mydialog.cpp I have

    Qt Code:
    1. #include "mydialog.h"
    2.  
    3. MyDialog::MyDialog(QWidget *parent)
    4. :MyDialog(parent)
    5. {
    6. ...
    7. }
    8.  
    9. MyDialog::~MyDialog()
    10. {
    11. ...
    12. }
    To copy to clipboard, switch view to plain text mode 

    Then in main.cpp I do this:

    Qt Code:
    1. #include "mydialog.h"
    2.  
    3. int main( int argc, char **argv )
    4. {
    5. QApplication a( argc, argv );
    6.  
    7. MyDialog w;
    8. w.show();
    9. return a.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 

    The examples that I have looked at do not appear to be based on qt3 code that is already subclassing the ui object and I am having a hard time figuring out how to make my code work with the new code generated by uic 4. It seems like I should be able to make some minor changes to MyDialog in mydialog.h and possibly mydialog.cpp to make this work. But everything I have tried will not build. Is there someone here that can modify my little example code stubs so that this would correctly interface to the code generated by uic 4? It does not need to be totally perfect just enough so that I know I am on the right track.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: port qt3 app to desinger 4 ui files

    Try:
    Qt Code:
    1. class MyDialog : public QDialog, public Ui::MyDialogBase
    2. {
    3. Q_OBJECT
    4. public:
    5. ...
    6. };
    7. ...
    8. MyDialog::MyDialog( QWidget *parent )
    9. : QDialog( parent )
    10. {
    11. setupUi( this );
    12. ...
    13. }
    To copy to clipboard, switch view to plain text mode 
    Although I prefer the single inheritance approach.

  3. #3
    Join Date
    Mar 2006
    Posts
    74
    Thanks
    1
    Qt products
    Qt3
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: port qt3 app to desinger 4 ui files

    Sorry that is basically what I had tried before. I tried it again to make sure. The compiler gives me an error message that points at the end of

    class MyDialog : public QDialog, public Ui::MyDialogBase

    in mydialog,h and says :

    mydialg.h:2: error: expected class-name before '{' token

    There could be something else wrong since I can not get the makefile generated by qmake to run uic or moc and I have been doing this by hand (what a pain the the rear). But I was able to get the app to build and run using uic3 before I converted the ui files.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: port qt3 app to desinger 4 ui files

    Try #include "ui_mydialogbase.h" (if your .ui file is called mydialogbase.ui). Make sure you re-run qmake.

  5. #5
    Join Date
    Mar 2006
    Posts
    74
    Thanks
    1
    Qt products
    Qt3
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: port qt3 app to desinger 4 ui files

    OK I was having problems with make not running uic and creating the ui header files. After updating all of the header to say things like

    #include <ui_mydialogbase.h>

    make started creating the ui header files. At that point for the most part this is now working. I do have two of the dialog implementations that are still giving me problems with the setupUI(this) statement. It compiles about 'setupUI' was not declared in this scope. If I comment this line out of both of the dialog implementations it will build and run. Of course none of the signals/slots work and there is lots of functionality that is broken because of that. I know that the setUI(this) line has to be there I just need to figure out why I am getting the compiler errors on two out of seven of these. I can't see why these two are different but it is late and I am tired so I will take a fresh look at it tomorrow.

    Thanks for your help I have gotten much farther along and I think I can get the port at least mostly working in the next few days.

Similar Threads

  1. Replies: 5
    Last Post: 22nd September 2006, 08:04
  2. UTF-16 files
    By jcr in forum Qt Programming
    Replies: 3
    Last Post: 7th September 2006, 12:43
  3. Replies: 16
    Last Post: 7th March 2006, 15:57
  4. [Win32/VC++ 8.0] Strange problems with qrc_*.cpp files
    By mloskot in forum Installation and Deployment
    Replies: 6
    Last Post: 6th March 2006, 10:28
  5. Visual Studio 2003 and .vcproj files
    By mbjerkne in forum General Discussion
    Replies: 2
    Last Post: 1st February 2006, 00:51

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.