Page 1 of 2 12 LastLast
Results 1 to 20 of 35

Thread: MFC Program in QT

  1. #1
    Join Date
    Jul 2007
    Posts
    166
    Thanks
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default MFC Program in QT

    Hi,
    I need to create a program, which one capture data from web camera using Qt 4.3.0 with Visual Studio 2005 ( VC ++ ) ( MFC program ). Can you help me for that? Please give a link to some examples for that.
    Please help me

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: MFC Program in QT

    Amm... I think you are mixing things...
    Do you mean you want to write an MFC program with visual studio, or do you mean you want to program a Qt application with the visual studio IDE ?
    I guess its the later.
    If so, please state the exact problem you need help with.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jul 2007
    Posts
    166
    Thanks
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: MFC Program in QT

    Hi,
    My probs is that, I need to create a program in Qt 4.3.0 and compile it using Visual Studio 2005 ( VC++ only). Through that program, I need to create a screen for capture images from a web camera. So I think about MFC. If any other way to create it, Please give me the tutorial for that.
    Please help me.

  4. #4
    Join Date
    Aug 2006
    Posts
    250
    Thanks
    19
    Thanked 49 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: MFC Program in QT

    Quote Originally Posted by sabeesh View Post
    Hi,
    My probs is that, I need to create a program in Qt 4.3.0 and compile it using Visual Studio 2005 ( VC++ only). Through that program, I need to create a screen for capture images from a web camera. So I think about MFC. If any other way to create it, Please give me the tutorial for that.
    Please help me.
    How would MFC help you? The window you can do with Qt. To get the webcam data you'll have to look at something like OpenCV. There might be other webcam access libs on windows but I've only used OpenCV so I don't know.

  5. #5
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: MFC Program in QT

    Hi,
    My probs is that, I need to create a program in Qt 4.3.0 and compile it using Visual Studio 2005 ( VC++ only). Through that program, I need to create a screen for capture images from a web camera. So I think about MFC. If any other way to create it, Please give me the tutorial for that.
    Please help me.
    If you say you need to create a Qt application, why are you thinking of MFC?
    Do you understand what MFC and Qt are?
    If it is a requirement for you to use Qt, you don't need MFC.
    On our wiki you can learn how to integrate Qt4 and MSVC, unless you are a commercial user of Qt, in that case you get a nice integration in to MSVC it self.
    Last edited by high_flyer; 14th December 2007 at 09:49.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  6. #6
    Join Date
    May 2007
    Posts
    301
    Thanks
    46
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: MFC Program in QT

    I think it is because he is using Visual Studio 2005 and that obviously comes with the MFC libraries. I use visual studio 2005 with a commercial version of QT which integrates into this environment.

  7. #7
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: MFC Program in QT

    I think it is because he is using Visual Studio 2005 and that obviously comes with the MFC libraries.
    Yes, but that doesn't mean he should use them.
    I think he does not understand what Qt and MFC are - look at the subject of the thread...
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  8. #8
    Join Date
    May 2007
    Posts
    301
    Thanks
    46
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: MFC Program in QT

    All depends on what he is comfortable with. I came from a background of having used MFC for 8 years and then recently moved to QT. The team I use to work with were all MFC developers and hence we stuck with it. Of course now, I am finding the switch to QT proving to be so much nicer and it helps me a lot more than MFC and also, this great site where people like yourself offer advice and help

  9. #9
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: MFC Program in QT

    All depends on what he is comfortable with.
    I think requirements come before the comfort, and he did state:
    My probs is that, I need to create a program in Qt 4.3.0 and compile it using Visual Studio 2005 ( VC++ only)
    MFC or Qt both are fine.
    I find mixing is not good, unless there is no way with out it, which doesn't look to be the case here, since he is starting a new application.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  10. #10
    Join Date
    May 2007
    Posts
    301
    Thanks
    46
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: MFC Program in QT

    In my experience of working for various companies, most of them won't give you the time to learn a new library unless their budget covers it - but hey, I may have worked for some 'bad' companies?!

    Requirements do play a BIG part of course and if certain requirements cannot be met using a certain library then obviously you look at alternatives.

    Mixing MFC with Qt in certain circumstances you have to, although as you point out, this is a new application so I agree, don't mix them, using one or the other is enough.

    Compiling a project in Visual Studio 2005 that uses Qt is simple with Qt VS-Integration, although you do need a commercial version of Qt.

    Why does it need to be compiled using VS2005?

  11. #11
    Join Date
    Jul 2007
    Posts
    166
    Thanks
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: MFC Program in QT

    Do you have any examples with OpenCV in Qt.
    Please give the link.

  12. #12
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: MFC Program in QT

    OpenCV is an external lib.
    There is nothing special about using it with Qt, use it just as you would in any other application.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  13. #13
    Join Date
    Aug 2006
    Posts
    250
    Thanks
    19
    Thanked 49 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: MFC Program in QT

    You should look at this: http://opencvlibrary.sourceforge.net/CameraCapture

    Instead of using cvShowImage, you would copy the data from the IPLImage and create a QImage to show in your Qt application.

  14. #14
    Join Date
    Jul 2007
    Posts
    166
    Thanks
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: MFC Program in QT

    Hi,
    Thankyou for your reply,
    I use that program. For convert the Image from IplImageToQImage to QImage, I use the function http://www.bernardotti.it/portal/showthread.php?t=597 . But It return *QImage. How can I display it?
    Sorry, Because I am not an expert in Qt. Please help me...

  15. #15
    Join Date
    Jul 2007
    Posts
    166
    Thanks
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Display q QImage

    Hi,
    I have a form in Qt 4.3 and through my program I create a QImage. I create a function from create this QImage and that function return *QImage and it store in another *QImage. How Can I display it in my from. I want to display this *QImage as a widget in my form. How can I do this?
    Please help me

  16. #16
    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: Display q QImage

    The easiest way is to convert that QImage to QPixmap and use QLabel.

    Please, don't ask the same question twice.

  17. #17
    Join Date
    Jul 2007
    Posts
    166
    Thanks
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: MFC Program in QT

    Hi,
    I do that like this,

    QImage *ImageVid;
    IplImage* frame = cvQueryFrame( capture );

    ImageVId = IplImageToQImage(frame);


    and the function is this, It return QImage *. How Can I display this QImage * in a Label, through QLabel->setPixmap().
    Because the property is " setPixmap ( const QPixmap & )"


    Qt Code:
    1. QImage * myQtApp::IplImageToQImage(const IplImage * iplImage) {
    2.  
    3. uchar *qImageBuffer = NULL;
    4. int width = iplImage->width;
    5.  
    6.  
    7. int widthStep = iplImage->widthStep;
    8. int height = iplImage->height;
    9.  
    10. switch (iplImage->depth) {
    11. case IPL_DEPTH_8U:
    12.  
    13. if (iplImage->nChannels == 1) {
    14.  
    15. // OpenCV image is stored with one byte grey pixel. We convert it
    16. // to an 8 bit depth QImage.
    17.  
    18. qImageBuffer = (uchar *) malloc(width*height*sizeof(uchar));
    19. uchar *QImagePtr = qImageBuffer;
    20. const uchar *iplImagePtr = (const uchar *) iplImage->imageData;
    21.  
    22. for (int y = 0; y < height; y++) {
    23. // Copy line by line
    24. memcpy(QImagePtr, iplImagePtr, width);
    25. QImagePtr += width;
    26. iplImagePtr += widthStep;
    27. }
    28.  
    29. } else if (iplImage->nChannels == 3) {
    30.  
    31. // OpenCV image is stored with 3 byte color pixels (3 channels).
    32. // We convert it to a 32 bit depth QImage.
    33.  
    34.  
    35. qImageBuffer = (uchar *) malloc(width*height*4*sizeof(uchar));
    36. uchar *QImagePtr = qImageBuffer;
    37. const uchar *iplImagePtr = (const uchar *) iplImage->imageData;
    38.  
    39. for (int y = 0; y < height; y++) {
    40. for (int x = 0; x < width; x++) {
    41. // We cannot help but copy manually.
    42. QImagePtr[0] = iplImagePtr[0];
    43. QImagePtr[1] = iplImagePtr[1];
    44. QImagePtr[2] = iplImagePtr[2];
    45. QImagePtr[3] = 0;
    46. QImagePtr += 4;
    47. iplImagePtr += 3;
    48. }
    49.  
    50. iplImagePtr += widthStep-3*width;
    51. }
    52.  
    53. } else {
    54. qDebug("IplImageToQImage: image format is not supported : depth=8U and %d channels\n", iplImage->nChannels);
    55.  
    56. }
    57.  
    58. break;
    59. default:
    60. qDebug("IplImageToQImage: image format is not supported : depth=%d and %d channels\n", iplImage->depth, iplImage->nChannels);
    61.  
    62. }
    63.  
    64. QImage *qImage;
    65. QImage qImag;
    66. if (iplImage->nChannels == 1) {
    67. QRgb *colorTable = new QRgb[256];
    68.  
    69. for (int i = 0; i < 256; i++)
    70. colorTable[i] = qRgb(i, i, i);
    71. qImage = new QImage(qImageBuffer, width, height, QImage::Format_RGB32);
    72. QImage qImag(qImageBuffer, width, height, QImage::Format_RGB32 );
    73.  
    74. } else {
    75. qImage = new QImage(qImageBuffer, width, height, QImage::Format_RGB32);
    76. QImage qImag(qImageBuffer, width, height, QImage::Format_RGB32 );
    77. }
    78.  
    79. return qImage;
    80.  
    81. }
    To copy to clipboard, switch view to plain text mode 

    Please help me to solve this probs...
    Last edited by jacek; 17th December 2007 at 12:42. Reason: missing [code] tags

  18. #18
    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: MFC Program in QT

    Quote Originally Posted by sabeesh View Post
    Because the property is " setPixmap ( const QPixmap & )"
    You have to convert QImage to QPixmap first. Check static methods of QPixmap in the docs.


    Qt Code:
    1. ...
    2. QImage *qImage;
    3. QImage qImag;
    4. if (iplImage->nChannels == 1) {
    5. QRgb *colorTable = new QRgb[256];
    6.  
    7. for (int i = 0; i < 256; i++)
    8. colorTable[i] = qRgb(i, i, i);
    9. qImage = new QImage(qImageBuffer, width, height, QImage::Format_RGB32);
    10. QImage qImag(qImageBuffer, width, height, QImage::Format_RGB32 );
    11.  
    12. } else {
    13. qImage = new QImage(qImageBuffer, width, height, QImage::Format_RGB32);
    14. QImage qImag(qImageBuffer, width, height, QImage::Format_RGB32 );
    15. }
    16.  
    17. return qImage;
    18. }
    To copy to clipboard, switch view to plain text mode 
    What do you need qImag and colorTable for?

  19. #19
    Join Date
    Jul 2007
    Posts
    166
    Thanks
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: MFC Program in QT

    Hi,
    I use that link ( http://opencvlibrary.sourceforge.net/CameraCapture ) for Qt. I face two probs in my program.
    1. How can avoid cvNamedWindow( "mywindow", CV_WINDOW_AUTOSIZE );
    Because in Qt, I have a window and I need to display the image in that window. When I comment this line then the Image is not display in my Qt Widget.

    2. When I use this function ( http://groups.google.com/group/OpenC...encv+qt&rnum=2 ) for copy IplImage To QImage, i can copy and display the image. But the image is display as 90 degree rotated. How can I solve these two probs.

    Please Help me...

  20. #20
    Join Date
    Jul 2007
    Posts
    166
    Thanks
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: MFC Program in QT

    Hi,
    No reply?????????????

Similar Threads

  1. Replies: 5
    Last Post: 29th October 2007, 22:49
  2. Version setting in QT Program
    By sabeesh in forum Qt Programming
    Replies: 4
    Last Post: 24th October 2007, 12:07
  3. How do I make a program out of my program?
    By Randulf in forum Newbie
    Replies: 1
    Last Post: 29th May 2007, 11:11
  4. QT MySQL
    By sabeeshcs in forum Newbie
    Replies: 6
    Last Post: 12th January 2007, 04:19
  5. Enter key causing program to exit
    By welby in forum Qt Programming
    Replies: 2
    Last Post: 9th March 2006, 16:11

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.