PDA

View Full Version : Draw rubberband line



Pang
11th September 2006, 09:35
hi,I can not drawing a rubberband line with Qt 4.1.4 (linux),has anybody can help me? thanks a lot

jpn
11th September 2006, 09:46
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).

Uwe
11th September 2006, 11:19
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

cdemirkir
13th July 2007, 15:38
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 ?


ImageMarker::ImageMarker()
{
imageLabel = new QLabel;
imageLabel->setBackgroundRole(QPalette::Base);
imageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
imageLabel->setScaledContents(true);

scrollArea = new QScrollArea;
scrollArea->setBackgroundRole(QPalette::Dark);
scrollArea->setWidget(imageLabel);
setCentralWidget(scrollArea);

//rubberBand = new QRubberBand(QRubberBand::Rectangle, imageLabel);

picker = new QwtPicker();
picker->setTrackerMode(QwtPicker::ActiveOnly);
connect(picker, SIGNAL(selected(const QwtPolygon &)), this, SLOT(selected(const QwtPolygon &)));
picker->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::DragSelection);
picker->setRubberBand(QwtPicker::RectRubberBand);

createActions();
createMenus();

setWindowTitle(tr("Image Marker"));
resize(500, 400);
}

jacek
14th July 2007, 00:09
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?