Scott Liu
4th September 2009, 04:04
Hi, all.
I want to show a MS Word document in a graphicsView, so I add a QAxWidget into the graphicsView,it indeed add the QAxWidget in. BUT the Word document doesn't show. I can't find the problem. Is there anybody knows how to show a Word document in the QAxWidget which is part of graphicsView? Any idea is welcomed. please.
The following is my code:
You should add
CONFIG += qaxcontainer
into the pro file .
//main.cpp
#include <QtGui/QApplication>
#include "mainwindow.h"
#include <QWidget>
#include <QVBoxLayout>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QLineEdit>
#include <QGraphicsProxyWidget>
#include <QSlider>
#include <QLabel>
#include <QAxWidget>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget *panel = new QWidget();
QVBoxLayout *layout = new QVBoxLayout(panel);
panel->resize(600,600);
layout->addWidget(new QLabel("Run this a couple of times under Carbon and Cocoa, in Cocoa the proxys do not move."));
QGraphicsScene *scene = new QGraphicsScene(panel);
QGraphicsView *view = new QGraphicsView(scene);
layout->addWidget(view);
QLineEdit *lineEdit1 = new QLineEdit("edit 1 is going to hide now.");
QGraphicsProxyWidget *item1 = new QGraphicsProxyWidget();
item1->setWidget(lineEdit1);
item1->setPos(10, 10);
scene->addItem(item1);
QLineEdit *lineEdit2 = new QLineEdit("edit 2");
QGraphicsProxyWidget *item2 = new QGraphicsProxyWidget();
item2->setWidget(lineEdit2);
item2->setPos(10, 40);
scene->addItem(item2);
QSlider *slider = new QSlider(Qt::Horizontal);
QGraphicsProxyWidget *item3 = new QGraphicsProxyWidget();
item3->setWidget(slider);
item3->setPos(10, 70);
scene->addItem(item3);
QAxWidget *axwidget = new QAxWidget;
QGraphicsProxyWidget *item4 = new QGraphicsProxyWidget();
item4->setWidget(axwidget);
item4->setPos(10, 110);
scene->addItem(item4);
axwidget->setControl("E:/ss.doc");
panel->show();
return app.exec();
}
I want to show a MS Word document in a graphicsView, so I add a QAxWidget into the graphicsView,it indeed add the QAxWidget in. BUT the Word document doesn't show. I can't find the problem. Is there anybody knows how to show a Word document in the QAxWidget which is part of graphicsView? Any idea is welcomed. please.
The following is my code:
You should add
CONFIG += qaxcontainer
into the pro file .
//main.cpp
#include <QtGui/QApplication>
#include "mainwindow.h"
#include <QWidget>
#include <QVBoxLayout>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QLineEdit>
#include <QGraphicsProxyWidget>
#include <QSlider>
#include <QLabel>
#include <QAxWidget>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget *panel = new QWidget();
QVBoxLayout *layout = new QVBoxLayout(panel);
panel->resize(600,600);
layout->addWidget(new QLabel("Run this a couple of times under Carbon and Cocoa, in Cocoa the proxys do not move."));
QGraphicsScene *scene = new QGraphicsScene(panel);
QGraphicsView *view = new QGraphicsView(scene);
layout->addWidget(view);
QLineEdit *lineEdit1 = new QLineEdit("edit 1 is going to hide now.");
QGraphicsProxyWidget *item1 = new QGraphicsProxyWidget();
item1->setWidget(lineEdit1);
item1->setPos(10, 10);
scene->addItem(item1);
QLineEdit *lineEdit2 = new QLineEdit("edit 2");
QGraphicsProxyWidget *item2 = new QGraphicsProxyWidget();
item2->setWidget(lineEdit2);
item2->setPos(10, 40);
scene->addItem(item2);
QSlider *slider = new QSlider(Qt::Horizontal);
QGraphicsProxyWidget *item3 = new QGraphicsProxyWidget();
item3->setWidget(slider);
item3->setPos(10, 70);
scene->addItem(item3);
QAxWidget *axwidget = new QAxWidget;
QGraphicsProxyWidget *item4 = new QGraphicsProxyWidget();
item4->setWidget(axwidget);
item4->setPos(10, 110);
scene->addItem(item4);
axwidget->setControl("E:/ss.doc");
panel->show();
return app.exec();
}