qt判断窗口是否已显示,如何在C ++和QT的另一个窗口中显示主窗口的结果图像?...

在Qt项目中,作者尝试从文件选择图像,将其转换为灰度图,并在新窗口中显示。问题在于,转换过程中出现错误,导致图像无法在第二个窗口中显示。解决方案包括在新窗口中创建一个设置图像的方法,以及正确地将cv::Mat转换为QImage。正确的代码实现解决了这个问题。
摘要由CSDN通过智能技术生成

I am currently working on Qt creator. I want to just get an image by browsing from hard drive in mainwindow and then after converting the RGB color image to gray image, I want to display the gray image in the another window.

By clicking the button "Browse", color image can be loaded where color to gray image conversion will be applied. Here grayImage is a public Mat type variable. At the same time an instance of another window named SecondDialog will be called to be executed.

void MainWindow::on_Browse_clicked()

{

QFileDialog dialog(this);

dialog.setNameFilter(tr("Images (*.png *.xpm *.jpg)"));

dialog.setViewMode(QFileDialog::Detail);

fileName = QFileDialog::getOpenFileName(this, tr("Open Images"), "/home/rpi/Desktop/Picture/Sample Pictures", tr("Image Files (*.png *.jpg *.bmp)"));

if

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值