# Open CV Casting variables problem in QT Creator (C++)

**URL:** <https://forum.opencv.org/t/open-cv-casting-variables-problem-in-qt-creator-c/9688>\
**Category:** C++\
**Tags:** qt, core\
**Created:** [July 29, 2022, 10:49pm UTC](https://forum.opencv.org/t/open-cv-casting-variables-problem-in-qt-creator-c/9688 "2022-07-29T22:49:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kamil\_Jaworski](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/kamil_jaworski/32/4832_2.png) [@Kamil\_Jaworski](https://forum.opencv.org/u/Kamil_Jaworski)\
**Post date:** [July 29, 2022, 10:49pm UTC](https://forum.opencv.org/t/open-cv-casting-variables-problem-in-qt-creator-c/9688/1 "2022-07-29T22:49:22Z")

</div>

Hi,  
I’m trying to calibrate my camera using OpenCV library in QT Creator. I’m trying to display a `cv::Matx33f` and `cv::Vec` in QT using `qDebug()` console or `QPlainTextEdit` so I could see the result in my GUI, but I have no idea how to do it. I’ve been trying with QString(), QString::number() etc. and nothing seems to work for me.

```auto

cv::Matx33f Var1(Matx33f::eye());  
cv::Vec<float, 5> Var2(0, 0, 0, 0, 0); 

ui->calibParameters->appendPlainText(**QString()... "no idea how to convert"** );

```

errors:

```auto
No matching conversion for functional-style cast from 'cv::Matx33f' (aka 'Matx<float, 3, 3>') to 'QString' 
No matching conversion for functional-style cast from 'Vec<float, 5>' to 'QString'

```

Can someone help me with my ‘casting’ problem?

Thank you in advance

---

<div class="post-metadata">

**Author:** ![matti.vuori](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@matti.vuori](https://forum.opencv.org/u/matti.vuori)\
**Post date:** [July 30, 2022, 5:31am UTC](https://forum.opencv.org/t/open-cv-casting-variables-problem-in-qt-creator-c/9688/2 "2022-07-30T05:31:28Z")

</div>

There probably is no cast. You can write a small helper function to firmat the data as string, see [How to convert opencv mat into string c++ - Stack Overflow](https://stackoverflow.com/questions/61263971/how-to-convert-opencv-mat-into-string-c)

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [July 30, 2022, 6:34am UTC](https://forum.opencv.org/t/open-cv-casting-variables-problem-in-qt-creator-c/9688/3 "2022-07-30T06:34:40Z")

</div>

since you can write them out to `std::ostream`:

```
std::stringstream ss; 
ss << Var1 << " " << Var2 << endl;
ui->calibParameters->appendPlainText( QString(ss.str()) );

```

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [July 30, 2022, 10:43am UTC](https://forum.opencv.org/t/open-cv-casting-variables-problem-in-qt-creator-c/9688/4 "2022-07-30T10:43:57Z")

</div>

apart from `std::ostream`, I would have expected a cast to `char*` or `std::string` to maybe work, but not `QString`, because OpenCV has no clue what that is.
