Results 1 to 5 of 5

Thread: Draw rubberband line

  1. #1
    Join Date
    Sep 2006
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    2

    Default Draw rubberband line

    hi,I can not drawing a rubberband line with Qt 4.1.4 (linux),has anybody can help me? thanks a lot

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: Draw rubberband line

    Please be more specific. What have you tried so far? How are you using it? How can you not "draw" it? Have you noticed the example code in QRubberBand docs (Detailed Description).
    J-P Nurmi

  3. #3
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,326
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 880 Times in 828 Posts

    Default Re: Draw rubberband line

    You might look at QwtPicker from Qwt (http://qwt.sf.net). It offers rubberband supported selections on any type of widgets in a very easy way:

    QwtPicker *picker = new QwtPicker(yourWidget);
    picker->setSelectionFlags(QwtPicker::RectSelection | ...);
    connect(picker, SIGNAL(selected(const QPolygonF &)), ...);

    In case of QwtPicker::RectSelection the QPolygonF, that is emitted, consists of the cormers of the selected rectangle.

    The "bode" example of Qwt shows how to zoom with such a picker.

    HTH,
    Uwe

  4. #4
    Join Date
    Jul 2007
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Draw rubberband line

    Dear Uwe
    I'd like to implement QwtPicker based zoom but when I implement the following code corresponding my image viewer class constructor I get the
    QObject : Cannot create a children for a parent that is in a different thread
    error message in console. Could you help me to resolve this problem ?

    Qt Code:
    1. ImageMarker::ImageMarker()
    2. {
    3. imageLabel = new QLabel;
    4. imageLabel->setBackgroundRole(QPalette::Base);
    5. imageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    6. imageLabel->setScaledContents(true);
    7.  
    8. scrollArea = new QScrollArea;
    9. scrollArea->setBackgroundRole(QPalette::Dark);
    10. scrollArea->setWidget(imageLabel);
    11. setCentralWidget(scrollArea);
    12.  
    13. //rubberBand = new QRubberBand(QRubberBand::Rectangle, imageLabel);
    14.  
    15. picker = new QwtPicker();
    16. picker->setTrackerMode(QwtPicker::ActiveOnly);
    17. connect(picker, SIGNAL(selected(const QwtPolygon &)), this, SLOT(selected(const QwtPolygon &)));
    18. picker->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::DragSelection);
    19. picker->setRubberBand(QwtPicker::RectRubberBand);
    20.  
    21. createActions();
    22. createMenus();
    23.  
    24. setWindowTitle(tr("Image Marker"));
    25. resize(500, 400);
    26. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jacek; 14th July 2007 at 00:08. Reason: missing [code] tags

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: Draw rubberband line

    Quote Originally Posted by cdemirkir View Post
    QObject : Cannot create a children for a parent that is in a different thread
    error message in console. Could you help me to resolve this problem ?
    Do you use threads in your application?

Similar Threads

  1. Draw QtCanvasElipse on mouse press event position
    By YuriyRusinov in forum Newbie
    Replies: 1
    Last Post: 31st May 2006, 12:57
  2. Howto draw stuff
    By Morea in forum Newbie
    Replies: 16
    Last Post: 7th April 2006, 13:05
  3. Draw a rectangle alternating two colors with qPainter
    By SkripT in forum Qt Programming
    Replies: 12
    Last Post: 25th January 2006, 00:12
  4. Drawing over content widgets? (overlay)
    By sertrem in forum Qt Programming
    Replies: 2
    Last Post: 17th January 2006, 23:18
  5. Draw on a QTableWidget
    By Corran in forum Qt Programming
    Replies: 6
    Last Post: 6th January 2006, 23:17

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
  •  
Qt is a trademark of The Qt Company.