Unsolved QSizeGrip is not visibile inside the QRubberBand when compiled on OSX.
-
Hi,
I may be wrong but IIRC, on OS X there's no visible size grip thus QSizeGrip follows that.
-
So if you were right, is there any alternative to risize the QRubberband?
-
so besides not showing it, it cannot resize ? Nothing happens if u drag where QSizeGrip should have been drawn?
-
@mrjj yes, draging the QRubberBand is the only thing that i can do. I cannot resize it since the QSizeGrip is not shown. Do you have any idea or alternative to this issue?
-
@CarLoowwww
So the QSizeGrip you create , are disabled by Osx??
I thought it was merely a visual thing and they are drawn differently but you say they are completely removed? -
@mrjj yes, i took some research about QSizeGrip, and they completely removed it on OSX platform. So im looking on a way to resize the QRubberBand when i drag it on its corner.
-
@CarLoowwww
Well you can maybe reuse some code from here
https://gist.github.com/IMAN4K/b2f251bfd2043b99e95160026979a8a6 -
Can you provide a complete sample code of your widget using QRubberBand ?
That will make it more easy to reproduce your use case.
-
ok here is the custom class of my QRubberBand.
#include <QSizeGrip> #include <QMouseEvent> #include <QHBoxLayout> #include <QGraphicsColorizeEffect> RubberBandCustomized::RubberBandCustomized(QWidget *parent) : QWidget(parent) { //here is buliding rubber band QHBoxLayout* layout = new QHBoxLayout(this); layout->setContentsMargins(0, 0, 0, 0); QSizeGrip* grip1 = new QSizeGrip(this); QSizeGrip* grip2 = new QSizeGrip(this); layout->addWidget(grip1, 0, Qt::AlignLeft | Qt::AlignTop); layout->addWidget(grip2, 0, Qt::AlignRight | Qt::AlignBottom); this->resize(100,100); rubberband = new QRubberBand(QRubberBand::Rectangle, this); QGraphicsColorizeEffect *ee = new QGraphicsColorizeEffect(rubberband); ee->setColor(QColor(0,0,0,0)); rubberband->setGraphicsEffect(ee); rubberband->show(); } void RubberBandCustomized::resizeEvent(QResizeEvent *e) { rubberband->resize(e->size()); }
and here is the code where i create my Custom Rubberband.
PhotoBoardPlugin_Dialog::PhotoBoardPlugin_Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::PhotoBoardPlugin_Dialog) { ui->setupUi(this); scene = new QGraphicsScene(this); ui->graphicsView->setScene(scene); ui->graphicsView->setStyleSheet( "QGraphicsView { border-style: none; }" ); ui->graphicsView->setStyleSheet( "QGraphicsView { background-color: rgb(0,0,0); }" ); //setting size to fit scene int scene_w = ui->graphicsView->width(); int scene_h = ui->graphicsView->height(); sourceImage = QImage(QString("://textureForTest/mardana_330x468.png")); sourceImage = sourceImage.scaled(QSize(scene_w,scene_h),Qt::KeepAspectRatio); m = QPixmap::fromImage(sourceImage); #ifdef Q_OS_MACX setWindowIcon(QIcon("")); ui->pushButton_2->setDefault(true); #endif int wc = ( scene_w - m.width())/2; int hc = ( scene_h - m.height())/2; pixmap = scene->addPixmap(m); pixmap->setPos(wc,hc); //pixmap->setFlag(QGraphicsItem::ItemIsMovable); rubberBand = new RubberBandCustomized(ui->graphicsView); rubberBand->move(150, 150); setWindowTitle(tr("Plugin - Photo Board")); }
Inside the whitebox there should be 2 QSizeGrip, but since it is not shown i am not able to resize the white box which is the QRubberBand that uses a QWidget with SubWindow Flag.
-
Your code can't be compiled, there are missing functions.
-
@SGaist Edited codes. I removed some function, since those function are just to make sure that the rubberband will not be moved beyond the border of the photo.
I also tried this sample Link to sample and compile it in two different platform(Using Windows and OSX). The Windows can freely resize the rubberband and working very well. While when i compiled it on OSX the initialization of the position and size of the rubberband are working but it has no resize handle/no interaction.