Results 1 to 7 of 7

Thread: Visual Studio .NET & QT

  1. #1
    Join Date
    Dec 2007
    Posts
    119
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Visual Studio .NET & QT

    Hi...I use Visual Studio .NET (2003) plus Qt 3.3.5. I've add the Qt toolbar in VS .NET but I've some problems in the interface (integration) between the 2 softwares.
    With Qt Designer I create myproject.pro and add some ui to this project, I import the project in VS creating so a VS project. Now if I make some changes in ui with Qt designer, this changes are applicated in VS too but reverse, if I make some changes in the source code with VS the aren't applicated in Qt Designer. Why is there this problem?

    And...using Qt Designer, I can't view the source of the mygui.ui...If a press right button of the mouse and Source, it tell my "Want you open a ui.h file?" and clicking yes it open a file ui.h blank? Why? Solutions?

  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: Visual Studio .NET & QT

    Quote Originally Posted by fruzzo View Post
    if I make some changes in the source code with VS the aren't applicated in Qt Designer. Why is there this problem?
    Does this mean that you edit the code generated automatically from .ui files?

  3. #3
    Join Date
    Dec 2007
    Posts
    119
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Visual Studio .NET & QT

    Quote Originally Posted by jacek View Post
    Does this mean that you edit the code generated automatically from .ui files?
    Yes I import the project .pro in VS...than I change code adding the body of members functions...
    I read about subclassing but I don't understand very well the mechanism

  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: Visual Studio .NET & QT

    Quote Originally Posted by fruzzo View Post
    Yes I import the project .pro in VS...than I change code adding the body of members functions...
    Is that the .ui.h file?

    Quote Originally Posted by fruzzo View Post
    I read about subclassing but I don't understand very well the mechanism
    It's not that hard, every .ui file represents a class, which you can subclass to add whatever functionality you need. The integration module probably can do that for you.

  5. #5
    Join Date
    Dec 2007
    Posts
    119
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Visual Studio .NET & QT

    Quote Originally Posted by jacek View Post
    Is that the .ui.h file?


    It's not that hard, every .ui file represents a class, which you can subclass to add whatever functionality you need. The integration module probably can do that for you.
    Qt 3.3 don't have integration module for VS.
    Now I'm think to pass to VS2005...there is something like QMsNetSetup.msi for adding Qt toolbar at VS2005?

  6. #6
    Join Date
    Dec 2007
    Posts
    119
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Visual Studio .NET & QT

    Quote Originally Posted by jacek View Post
    Is that the .ui.h file?
    no I create a gui called myGUI.ui.......than in VS I have myGUI.ui, myGUI.h and myGUI.cpp
    and I modify this last two.

  7. #7
    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: Visual Studio .NET & QT

    Quote Originally Posted by fruzzo View Post
    no I create a gui called myGUI.ui.......than in VS I have myGUI.ui, myGUI.h and myGUI.cpp
    and I modify this last two.
    I see, that's what I was afraid of. You shouldn't do that. There are even warnings in those files, which say that. It's because these files are automatically generated everytime you change the .ui file, which means that you will loose all your modifications.

    That's why you should use the subclassing approach (it will also save you a bit of pain, when you switch to Qt4). First you have to rename yourGUI.ui to yourGUISkel.ui (or youGUIBase.ui or whatever name you like) and also you will have to rename the widget from yourGUI to yourGUISkel (using Qt Designer). This way Qt will generate youGUISkel class instead of yourGUI. It's because you're going to write yourGUI yourself. It should look like this:
    Qt Code:
    1. // yourGUI.h
    2. #include "yourGUISkel.h"
    3.  
    4. class yourGUI : public yourGUISkel
    5. {
    6. Q_OBJECT
    7. yourGUI( QWidget * parent );
    8. ...
    9. };
    10.  
    11. // yourGUI.cpp
    12. #include "yourGUI.h"
    13.  
    14. yourGUI::yourGUI( QWidget * parent )
    15. : yourGUISkel( parent )
    16. {
    17. ...
    18. }
    To copy to clipboard, switch view to plain text mode 
    Since there is Q_OBJECT macro in yourGUI.h, you need yourGUI.moc file (qmake will make it for you --- you just have to add yourGUI.h to HEADERS variable and yourGUI.cpp to SOURCES in the .pro file and re-run qmake).

    Now you can safely edit the youGUISkel.ui file in Qt Designer and add implementation in yourGUI.{h,cpp} files.

Similar Threads

  1. Replies: 2
    Last Post: 23rd November 2007, 18:44
  2. Qt configure with msvc.net
    By jivanr in forum Installation and Deployment
    Replies: 1
    Last Post: 11th June 2007, 09:17
  3. Compile App using OpenGL and Visual Studios 2003
    By Rayven in forum General Programming
    Replies: 3
    Last Post: 26th April 2007, 16:43
  4. Qt Cryptographic Architecture
    By vermarajeev in forum Qt Programming
    Replies: 6
    Last Post: 9th February 2007, 14:15
  5. problem with linking
    By mickey in forum Qt Programming
    Replies: 49
    Last Post: 12th August 2006, 22: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.