Results 1 to 3 of 3

Thread: Visual Studio 10 with Qt Addin--Can I avoid running qmake -tp vc?

  1. #1
    Join Date
    Jun 2012
    Posts
    219
    Thanks
    28
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Visual Studio 10 with Qt Addin--Can I avoid running qmake -tp vc?

    I keep having problems for which the recommended solution seems to be "rerun qmake".

    Example, I just created a new exposure_controls.ui using Qt Designer and the only way I know to get a ui_exposure_controls.h is to:

    1) create a header file (call it exposure_controls.h") that defines a new class which:
    a) includes "ui_exposure_controls.h"
    b) defines a class (call it Exposure) which inherits from the class defined in exposure_controls.ui (and other Qt objects)
    c) has a Q_OBJECT macro

    2) Create an instance of the Exposure class.

    3) Run qmake -project;qmake QtApe1.pro; qmake -tp vc QtApe1.pro

    seems overly complicated--I suspect I'm missing something.

    Also while this is working for me, whenever I do step 3, a property sheet I have added to the Visual Studio 10 for non-QT libraries gets excluded. So, I have to re-add it each time after doing the qmake stuff.

    Seems like there should be a better way?

    Also--

    I have a MainWindow with a few slots and connects to simple methods. It's working, but now I wonder about "Best Practices". For example, I created a widget with sliders and push buttons. I want it to be displayed when one of the menu items is clicked.

    Do I just add that widget as a data member of the MainWindow class? Same for any associated methods? I'm worrying that I'll end up with a huge MainWindow class and that there might be a better way.

    Thanks,

    Dave Thomas

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Visual Studio 10 with Qt Addin--Can I avoid running qmake -tp vc?

    qmake will create a ui_*.h file for any *.ui file listed in the PRO file FORMS variable.

    The typical usage pattern for that intermediate ui_*.h file is through user-defined class as you describe. See Using a Designer UI File in Your Application for options. The header and source file for that user class should be listed in the pro file HEADERS and SOURCES variable respectively. You only need do this once, and you certainly should not be running "qmake -project", which creates a basic starter PRO file, routinely. Any time you modify the PRO file you need to re-run "qmake" once (not twice) and typically with no arguments other than a path to the PRO file if it is not in the current directory. Modifying the referenced UI, source, or header files does not generally require rerunning qmake unless you add or remove Q_OBJECT macros.

    I don't use the VC plugin but I would assume that most of this is done for you. Perhaps someone who does use it could shed light.


    For a pop-up dialog style of thing you would put the code for handling the dialog UI, e.g. interaction between widgets within the dialog etc., in the dialog class along with any access methods you need for outside users. The main window then only need to create an instance of the dialog class and exec() or show() it. Code to access the values in the dialog and do something with them has to exist somewhere, and the "correct" location is application dependent.

  3. #3
    Join Date
    Jun 2012
    Posts
    219
    Thanks
    28
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Visual Studio 10 with Qt Addin--Can I avoid running qmake -tp vc?

    Thanks for the quick reply!

    Right now I'm "evolving" from using fairly crude mechanisms in openCV's highgui to use Qt widgets instead. I'm doing one small bit at a time, so I'm really adding a QOBJECT frequently.

    So, I only need to run qmake once each time I add a QOBJECT But, when I run qmake -tp vc it detaches my property pages from the Visual Studio 10 project. I was hoping there was something I could do in Visual Studio so I wouldn't have to run qmake, or, do something so I don't have to redo the Visual Studio 10 properties after each qmake.

    Thanks for the guidance on how to organize the code.

    Dave Thomas

Similar Threads

  1. Replies: 1
    Last Post: 19th December 2011, 08:47
  2. Replies: 0
    Last Post: 27th September 2010, 13:33
  3. qt-vs-addin-1.1.5 crashes visual studio
    By jano_alex_es in forum Installation and Deployment
    Replies: 1
    Last Post: 30th June 2010, 19:08
  4. Release date for Visual Studio 2010 AddIn
    By Gargolissimus in forum Qt Tools
    Replies: 1
    Last Post: 3rd June 2010, 03:29
  5. $QTDIR value for Visual Studio addin
    By pparekh7 in forum Installation and Deployment
    Replies: 0
    Last Post: 5th February 2010, 00:18

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.