problem with QGraphicsProxyWidget
I reimplement my custom QGraphicsProxyWidget and i add it in my custom scene.
I reimplement the mousemove, mousepress and mouserelease event but i can't move it in my scene......why???
here the code:
Code:
QGraphicsProxyWidget::mouseMoveEvent(event);
}
QGraphicsProxyWidget::mouseReleaseEvent(mouseEvent);
}
scene()->clearSelection();
setSelected(true);
setCursor(Qt::ClosedHandCursor);
QGraphicsProxyWidget::mousePressEvent(mouseEvent);
}
i also set this flag in the constructor:
Code:
setFlag(QGraphicsProxyWidget::ItemIsMovable, true);
setFlag(QGraphicsProxyWidget::ItemIsSelectable, true);
setFlag(QGraphicsProxyWidget::ItemIsFocusable, true);
Re: problem with QGraphicsProxyWidget
You can not move the proxie!
Only QGraphicsItem family can move on
Code:
{
if (!IsSelectActive) {
return;
}
if (modus == Lock) {
return;
}
if (format == DIV_ABSOLUTE) {
if (modus == Move ) {
/* move resize top left frozing */
bool ChangeXY;
/* move from stop xy */
//////qDebug() << " move layer status ...............";
qreal WWxi = event->pos().x() - event->lastPos().x();
qreal HHyi = event->pos().y() - event->lastPos().y();
qreal diff = qMax ( HHyi , WWxi );
if (diff > 0) {
SetDimension( wi + WWxi , hi + HHyi );
ChangeXY = true;
} else {
if (wi > 100 && hi > 20) {
if (WWxi < 0) {
SetDimension( wi - 1 ,hi);
} else if (HHyi < 0) {
SetDimension( wi ,hi - 1);
}
ChangeXY = true;
}
}
/* normal move */
} else if ( modus == MoveAll ) {
if (!mount->txtControl()->editable()) {
setPos(event->scenePos() - event->lastPos());
event->accept();
}
}
}
ShowInfos();
if (mount->txtControl()->editable()) {
mount->txtControl()->procesevent(event);
}
}
or flags
QGraphicsProxyWidget become parent QGraphicsScene is not normal event!
Code:
{
fitInView(scene->sceneRect(), Qt::KeepAspectRatio);
}
demo /4.4.0_src/examples/graphicsview/padnavigator
you can try to static_cast from QEvent *e bool :: sceneEvent(QEvent *event) parent item
Re: problem with QGraphicsProxyWidget
How can i add to my scene a "table with rows and columns" using QGraphicsproxywidget??
adding a QTableWidget to my scene, i don't obtain the right behaviour.....that is
when i resize it, also the column and rows have to resize.....i'd also don't like to have the horizontal and vertical header, but just the columns and rows.
So i search an object like a QGraphicsRectItem filled with rows and columns......
How can i build it?
Re: problem with QGraphicsProxyWidget
what is your target sql table? image table? or print table? calendar....
point your mouse here ... it can make table....
http://www.qt-apps.org/content/show....?content=80234
Re: problem with QGraphicsProxyWidget
looking for the code, he adds the table using html language!!!!!!
Code:
void Layoutpainter::CreateanewTable()
{
QString subtext, collx, rowx,largo;
bool ok;
int colonne
= QInputDialog::getInteger(0, tr
("New Table cool"),tr
("Cool:"),
3,
1,
10,
1,
&ok
);
int righe
= QInputDialog::getInteger(0, tr
("New Table row"),tr
("Row:"),
3,
1,
100,
1,
&ok
);
largo = "100%";
if (colonne > 0 && righe > 0) {
tables.clear();
tables.
append(QString("<table border=\"1\" align=\"left\" width=\"%1\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#ffffff\">").
arg(largo
));
for (int i=0;i<righe;i++){
for (int o=0;o<colonne;o++){
tables.
append(QString("<td><p></p></td>"));
}
}
tables.
append(QString("</table>"));
subtext = tables.join("\n");
textCursor().insertFragment(fragment);
}
}
I think it isn't a great solution for me!! I'd like an image table(i don't have to fill it with any text), but i'd just like to set the number of columns and rows and their width.................
Re: problem with QGraphicsProxyWidget
another way is
from QStandardItemModel > QTextDocument
http://fop-miniscribus.googlecode.co....0/ModelSwap.h
http://fop-miniscribus.googlecode.co.../ModelSwap.cpp
and from QTextDocument to image.... QTextDocument->drawContents(device,qrect);