我在 Qt 中有 amainWindow
和 a 。Dialog
我在 MainWindow 打开两个图像。在我对 MainWindow 上的图像(裁剪、调整大小、旋转)进行操作之后。我想将图像发送给另一个window (QDialog)
. 我怎样才能把它作为一个发送parameter
?我的部分代码如下;
MainWindow::MainWindow()
{
openButton_1 = new QPushButton(tr("Open"));
cropButton_1 = new QPushButton(tr("Crop"));
rotateButton_1 = new QPushButton(tr("Rotate"));
resizeButton_1 = new QPushButton(tr("Resize"));
doneButton = new QPushButton(tr("Done"));
....
....
....
....
....
connect(openButton_1, SIGNAL(clicked()), this, SLOT(open1()));
connect(openButton_2, SIGNAL(clicked()), this, SLOT(open2()));
connect(doneButton, SIGNAL(clicked()), this, SLOT(done()));
// 打开新窗口的 done() 函数
void MainWindow::done()
{
CompareImage dialog(this);
dialog.exec();
}
// 新的对话窗口
CompareImage::CompareImage( QWidget *parent ) : QDialog( parent )
{
pushButton = new QPushButton(tr("TesT"));
graphicsScene = new QGraphicsScene;
graphicsView = new QGraphicsView(graphicsScene);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget( pushButton );
mainLayout->addWidget( graphicsView );
setLayout( mainLayout );
}
// 这里还有我的 open() 函数
void MainWindow::open( int signal )
{
QString fileName = QFileDialog::getOpenFileName(this,
tr("Open File"), QDir::currentPath());
if (!fileName.isEmpty()) {
QImage image(fileName);
if (image.isNull()) {
QMessageBox::information(this, tr("Image Viewer"),
tr("Cannot load %1.").arg(fileName));
return;
}
QGraphicsPixmapItem* item = new QGraphicsPixmapItem(QPixmap::fromImage(image));
if( signal == 1 )
{
graphicsScene_1->addItem(item);
graphicsView_1->show();
}
else if(signal == 2)
{
graphicsScene_2->addItem(item);
graphicsView_2->show();
}
}
}
使用它看起来不错,QGraphicsPixmapItem* item
但我做不到..你能帮我吗?谢谢你的想法..
> EDİT:这里也是我的 open1 和 open2 函数,可以清楚地了解情况..
void MainWindow::open1()
{
open( 1 );
}
void MainWindow::open2()
{
open( 2 );
}