Results 1 to 6 of 6

Thread: problem with QGraphicsProxyWidget

  1. #1
    Join Date
    Feb 2008
    Posts
    102
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question 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:
    Qt Code:
    1. void myproxy::mouseMoveEvent(QGraphicsSceneMouseEvent *event){
    2. QGraphicsProxyWidget::mouseMoveEvent(event);
    3. }
    4. void myproxy::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent){
    5. QGraphicsProxyWidget::mouseReleaseEvent(mouseEvent);
    6. }
    7. void myproxy::mousePressEvent ( QGraphicsSceneMouseEvent * mouseEvent ){
    8. scene()->clearSelection();
    9. setSelected(true);
    10. setCursor(Qt::ClosedHandCursor);
    11.  
    12. QGraphicsProxyWidget::mousePressEvent(mouseEvent);
    13. }
    To copy to clipboard, switch view to plain text mode 

    i also set this flag in the constructor:
    Qt Code:
    1. setFlag(QGraphicsProxyWidget::ItemIsMovable, true);
    2. setFlag(QGraphicsProxyWidget::ItemIsSelectable, true);
    3. setFlag(QGraphicsProxyWidget::ItemIsFocusable, true);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: problem with QGraphicsProxyWidget

    You can not move the proxie!
    Only QGraphicsItem family can move on
    Qt Code:
    1. void TextLayer::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
    2. {
    3. if (!IsSelectActive) {
    4. return;
    5. }
    6. if (modus == Lock) {
    7. return;
    8. }
    9. if (format == DIV_ABSOLUTE) {
    10. if (modus == Move ) {
    11. /* move resize top left frozing */
    12. bool ChangeXY;
    13. QGraphicsItem::setCursor(Qt::SizeAllCursor);
    14. /* move from stop xy */
    15. //////qDebug() << " move layer status ...............";
    16. qreal WWxi = event->pos().x() - event->lastPos().x();
    17. qreal HHyi = event->pos().y() - event->lastPos().y();
    18. qreal diff = qMax ( HHyi , WWxi );
    19. if (diff > 0) {
    20. SetDimension( wi + WWxi , hi + HHyi );
    21. ChangeXY = true;
    22. } else {
    23. if (wi > 100 && hi > 20) {
    24. if (WWxi < 0) {
    25. SetDimension( wi - 1 ,hi);
    26. } else if (HHyi < 0) {
    27. SetDimension( wi ,hi - 1);
    28. }
    29. ChangeXY = true;
    30. }
    31. }
    32. /* normal move */
    33. } else if ( modus == MoveAll ) {
    34. if (!mount->txtControl()->editable()) {
    35. QGraphicsItem::setCursor(Qt::ClosedHandCursor);
    36. setPos(event->scenePos() - event->lastPos());
    37. event->accept();
    38. }
    39. }
    40. }
    41. ShowInfos();
    42. if (mount->txtControl()->editable()) {
    43. mount->txtControl()->procesevent(event);
    44. }
    45. QGraphicsItem::mouseMoveEvent(event);
    46. }
    To copy to clipboard, switch view to plain text mode 

    or flags

    QGraphicsProxyWidget become parent QGraphicsScene is not normal event!

    Qt Code:
    1. void resizeEvent(QResizeEvent *event)
    2. {
    3. QGraphicsView::resizeEvent(event);
    4. fitInView(scene->sceneRect(), Qt::KeepAspectRatio);
    5. }
    To copy to clipboard, switch view to plain text mode 

    demo /4.4.0_src/examples/graphicsview/padnavigator


    you can try to static_cast from QEvent *e bool :: sceneEvent(QEvent *event) parent item

  3. #3
    Join Date
    Feb 2008
    Posts
    102
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question 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?

  4. #4
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default 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

  5. #5
    Join Date
    Feb 2008
    Posts
    102
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Re: problem with QGraphicsProxyWidget

    looking for the code, he adds the table using html language!!!!!!

    Qt Code:
    1. void Layoutpainter::CreateanewTable()
    2. {
    3.  
    4. QString subtext, collx, rowx,largo;
    5. bool ok;
    6. int colonne = QInputDialog::getInteger(0, tr("New Table cool"),tr("Cool:"), 3, 1, 10, 1, &ok);
    7. int righe = QInputDialog::getInteger(0, tr("New Table row"),tr("Row:"), 3, 1, 100, 1, &ok);
    8. largo = "100%";
    9. if (colonne > 0 && righe > 0) {
    10. QStringList tables;
    11. tables.clear();
    12. tables.append(QString("<table border=\"1\" align=\"left\" width=\"%1\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#ffffff\">").arg(largo));
    13. for (int i=0;i<righe;i++){
    14. tables.append(QString("<tr>"));
    15. for (int o=0;o<colonne;o++){
    16. tables.append(QString("<td><p></p></td>"));
    17. }
    18. tables.append(QString("</tr>"));
    19. }
    20. tables.append(QString("</table>"));
    21.  
    22. subtext = tables.join("\n");
    23. QTextDocumentFragment fragment = QTextDocumentFragment::fromHtml(subtext);
    24. textCursor().insertFragment(fragment);
    25. }
    26. }
    To copy to clipboard, switch view to plain text mode 

    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.................

  6. #6
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default 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);

Similar Threads

  1. problem with paint and erase in frame
    By M.A.M in forum Qt Programming
    Replies: 9
    Last Post: 4th May 2008, 20:17
  2. problem with opengl, zooming, drawpixels, and origin
    By ntp in forum General Programming
    Replies: 0
    Last Post: 22nd February 2008, 21:48
  3. Tricky problem with ARGB widget / UpdateLayeredWindow
    By nooky59 in forum Qt Programming
    Replies: 3
    Last Post: 21st February 2008, 10:35
  4. Graphics view display problem.
    By kiranraj in forum Qt Programming
    Replies: 3
    Last Post: 20th July 2007, 07:08
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.