Qt World Summit: Submit your Presentation

[CLOSED] How to create a resizable QLabel, the label should be resizable through mouse

  • The code below puts a sizegrip onto the Qlabel but if i try to resize the label, the mainwindow gets resized instead.

    @void aViewer::on_actionCrop_triggered()
    label= new QLabel(this->ui->graphicsView);
    sizeGrip= new QSizeGrip(this->label);
    label->setSizePolicy( QSizePolicy::Ignored,QSizePolicy::Ignored);
    label->setFixedSize(500, 600);
    label->setStyleSheet("background-color: rgba(0, 0, 0, 40%)");


  • That's what the documentation of QSizeGrip also states:
    Put this widget anywhere in a widget tree and the user can use it to resize the top-level window or any widget with the Qt::SubWindow flag set. [/quote]

    You could try to see what happens if you set the Qt::SubWindow flag on your label, but I have no idea if that will start behaving funny...

  • I figured out the right way. I created a new class and inherited QLabel, and added QSizegrip and eveything is working fine, but QSizegrip appears at top left pos instead of right bottom, and thats causing some problem in updating co-ordinates . Is it possible to make QSizeGrip appear at bottom right. I searched a lot in the Doc, but couldn't find any function.

  • Without you showing us your code, it's hard to point out your mistake...

  • We're continuing this discussion in "this":/forums/viewthread/16199 topic.

    This topic is closed.

Log in to reply