Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Design QFrame and QSizeGrip

Tags:

c++

qt

I created a QFrame and added a layout which contain QSizeGrip to resize that QFrame.

Here is my code.pp:

DragWidget::DragWidget(QWidget *parent)
    : QFrame(parent)
{
    setFrameStyle(QFrame::Sunken | QFrame::StyledPanel);
    //Set flag to resize
    setWindowFlags(Qt::SubWindow);
    QGridLayout *layout = new QGridLayout(this);
    layout->setContentsMargins(QMargins());
    layout->setSpacing(0);
    //Add size grip (to resize) to layout
    QSizeGrip * sizeGrip = new QSizeGrip(this);
    layout->addWidget(sizeGrip, 0, 0, 1, 1, Qt::AlignBottom | Qt::AlignRight);
}

I want to design that QFrame has a background like this:

enter image description here

Moreover is there any way to customize the icon resize of QSizeGrip (make it more clearly...).

enter image description here

like image 449
user2652023 Avatar asked Nov 24 '25 21:11

user2652023


1 Answers

You can customize the QSizeGrip using style sheet. Here an example: Customizing QSizeGrip

Here the Qt style sheet documentation: Qt Style Sheets

In your case you can add this line of code:

sizeGrip->setStyleSheet("QSizeGrip { image: url(yourFolder/yourImage.png); }");

In a similar way you can customize the QFrame background, setting an image that will be repeated. See Customizing QFrame and List of properties

EDIT

Another approach is subclassing the QSizeGrip and reimplement the paintEvent() method (and maybe sizeHint() depending on the icon size). Here an example Analog Clock Example

like image 58
Fabio Avatar answered Nov 26 '25 12:11

Fabio



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!