【发布时间】:2022-10-02 21:49:56
【问题描述】:
我想在新窗口中显示我的图像。所以我试图通过构造函数将图像的路径作为值传递
void DicomWidget::mouseDoubleClickEvent(QMouseEvent *event){
qDebug() << ui->diWidget->whatsThis();
QString path = ui->diWidget->whatsThis();
EditWindow * editWindow = new EditWindow(this);
editWindow->setWindowTitle(path);
editWindow->setWhatsThis(path);
editWindow->show();
}
我想在构造函数中传递路径,但如果我这样做,editwindow 的 UI 不会呈现
我的editwindow.cpp
#include \"editwindow.h\"
#include \"ui_editwindow.h\"
EditWindow::EditWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::EditWindow)
{
ui->setupUi(this);
}
EditWindow::~EditWindow()
{
delete ui;
}
//Here i need to have refernce to this how shoul i give it
EditWindow::EditWindow(QString& filepath){
QFile file (filepath);
QFileInfo fileInfo(file.fileName());
QString filename(fileInfo.fileName());
QString name = filename;
currentDicomPath = filepath;
}
void EditWindow::on_pushButton_clicked()
{
currentDicomPath = EditWindow::windowTitle();
qDebug() <<\"Hello9\" << currentDicomPath;
}
-
您真的将图像的路径存储在QWidget::whatsThis() 中吗?我怀疑是...
-
我尝试通过构造函数,但我不能通过构造函数传递它,如果我这样做,新窗口不会呈现