Results 1 to 4 of 4

Thread: Issue with QGraphicsLinearLayout (Qt-4.4 snapshot)

  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    258
    Thanks
    22
    Thanked 19 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Issue with QGraphicsLinearLayout (Qt-4.4 snapshot)

    I went through the ordeal of downloading a recent Qt-4.4.0 snapshot (it's about two days old) over a 56kbit modem line in order to test the new QGraphicsView capabilities. I was most interested in using the Widget on canvas feature and the new QGraphics-layout-managers. None of them work for me. I will focus on the issue with the linearLayout in this post.
    I have pasted a little application below that highlights my problems. The layout works in so far that the QGraphicsWidgets are placed into the layout and handled properly. But the setSpacing member doesn't work as expected. If I set a spacing of 0, then all the items are painted on top of each other so that the result looks like a single item while the default spacing of 4 pixels creates a condensed heap of items. I have to resort to a spacing greater then the size of the items themselves in order to make them appear side by side. What am I doing wrong?

    Thanx in advance

    Qt Code:
    1. #include <QtGui>
    2.  
    3. class Panel : public QGraphicsWidget
    4. {
    5. Q_OBJECT
    6. public:
    7. Panel(QGraphicsItem * parent = 0, Qt::WindowFlags wFlags = 0) :
    8. QGraphicsWidget(parent, wFlags) {
    9. rect = QRectF(0, 0, 40, 40);
    10. setGeometry(rect);
    11. }
    12. void paint(QPainter* painter,
    13. const QStyleOptionGraphicsItem*, QWidget* widget = 0) {
    14. Q_UNUSED(widget);
    15. painter->setRenderHints(QPainter::Antialiasing);
    16. QPen pen(Qt::black);
    17. pen.setWidth(1);
    18. painter->setPen(pen);
    19. painter->setBrush(Qt::BDiagPattern);
    20. painter->drawEllipse(rect);
    21. }
    22. private:
    23. QRectF rect;
    24. };
    25.  
    26. class MainWindow : public QMainWindow
    27. {
    28. Q_OBJECT
    29. public:
    30. MainWindow(QWidget* parent=0) : QMainWindow(parent) {
    31. resize(800, 600);
    32. QGraphicsWidget* container = new QGraphicsWidget;
    33. m_lo = new QGraphicsLinearLayout;
    34. m_lo->setOrientation(Qt::Horizontal);
    35. m_lo->setSpacing(30);
    36. container->setLayout(m_lo);
    37. scene->addItem(container);
    38. for (int i = 0; i < 10; i++) {
    39. QGraphicsLinearLayout* row = new QGraphicsLinearLayout;
    40. row->setOrientation(Qt::Vertical);
    41. row->setSpacing(30);
    42. m_lo->addItem(row);
    43. for (int j = 0; j < 10; j++) {
    44. Panel* p = new Panel;
    45. row->addItem(p);
    46. }
    47. }
    48. QGraphicsView* view = new QGraphicsView(scene);
    49. setCentralWidget(view);
    50. }
    51. private:
    52. QGraphicsLinearLayout* m_lo;
    53. };
    54.  
    55. int main(int argc, char** argv)
    56. {
    57. QApplication app(argc, argv);
    58. MainWindow mw;
    59. mw.show();
    60. return app.exec();
    61. }
    62. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    258
    Thanks
    22
    Thanked 19 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Issue with QGraphicsLinearLayout (Qt-4.4 snapshot)

    Really no Idea on how to deal with this or shouldn't I mess around with pre-releases anyway?
    Last edited by momesana; 5th January 2008 at 19:21.

  3. #3
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Issue with QGraphicsLinearLayout (Qt-4.4 snapshot)

    Hi,

    It may be a good idea to look at the pre-release when you're strongly seeking for some feature or are as good as to find errors by yourself. Anyway, good luck. : )

    Kacper
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    258
    Thanks
    22
    Thanked 19 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Issue with QGraphicsLinearLayout (Qt-4.4 snapshot)

    Quote Originally Posted by maverick_pol View Post
    Hi,

    It may be a good idea to look at the pre-release when you're strongly seeking for some feature or are as good as to find errors by yourself. Anyway, good luck. : )

    Kacper
    Well, if you mean the technical preview by pre-release, I also downloaded that. Same issues there. I even do not have the widget on canvas example built that is being praised by so many reviewers on the internet. I wonder what I did wrong when compiling it. But, I don't care too much. In a few months, Qt-4.4 is being released anyway. I just have to be a little patient .

Similar Threads

  1. Mac--works w/latest snapshot, but not w/Qt 4.3
    By ber_44 in forum Installation and Deployment
    Replies: 2
    Last Post: 8th August 2007, 16:26
  2. qt3 to qt4 - uic issue
    By hvengel in forum Qt Programming
    Replies: 10
    Last Post: 4th March 2007, 02:59
  3. Replies: 5
    Last Post: 22nd September 2006, 08:04
  4. Qt 4.1.1 snapshot on windows
    By ldindon in forum Installation and Deployment
    Replies: 4
    Last Post: 13th February 2006, 13:58

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.