Skip to content
QtWS25 Last Chance
  • 0 Votes
    4 Posts
    524 Views
    A
    @JonB Thats fine, at least I don't have to unpolish first. Although I still think there is a bug because you don't have to polish the QComboBox's ItemView when it is not inside a QTabWidget or QStackedWidget.
  • Background for QStaticText by html

    Solved General and Desktop html css qstatictext
    3
    0 Votes
    3 Posts
    426 Views
    E
    @Chris-Kawa thanks 🙏
  • 0 Votes
    3 Posts
    743 Views
    Lucky01L
    @Paul-Colby thanks this is really helpful
  • 0 Votes
    5 Posts
    954 Views
    EmrecpE
    @SGaist Wow thank you very much! I fixed with pt.setClipPath(path2, Qt.ClipOperation.ReplaceClip) Some part of total code: progress_filled_width = self.value()/self.maximum()*self.width() pt.setClipPath(path2, Qt.ClipOperation.ReplaceClip) for i in range(100):
  • Stylesheet css or xml widgets pyqt6 python

    Solved Qt 6 stylesheet css xml qtwidgets python
    5
    0 Votes
    5 Posts
    2k Views
    J
    @jsulm Thank you very much ! It's exactly what I needed. In the top !
  • QTabWidget style the top buttons...

    Unsolved General and Desktop qtabwidget qstyle qstylesheet css
    8
    0 Votes
    8 Posts
    2k Views
    D
    @Ketan__Patel__0011 said in QTabWidget style the top buttons...: @Dariusz said in QTabWidget style the top buttons...: FUSION If you want to set "FUSION" Style for your application add this line in your main function qApp->setStyle(QStyleFactory::create("Fusion")); Hey Yeah that's the style im using. I'm trying to reproduce in css the button style now with black outline, then the white "ping" of border and gradient background. Are there any more style presets I can download? I know there is also windows/windowvista ones but... more ? There seem to be a large preset/plugin system build for styles but I dont see any on web available for use... mhmm ?
  • 1 Votes
    8 Posts
    8k Views
    M
    Thanks @Bonnie, You are AWESOME!
  • 0 Votes
    6 Posts
    2k Views
    S
    @A-A-SEZEN said in QTableWidget's width behaves strangely when applying any CSS: Check QTableWidget font, before css and after. Just changed the font to Consolas. Anyways, adding ui->tableWidget_memory->horizontalHeader()->resizeSections(QHeaderView::ResizeMode::ResizeToContents); to my code solved this problem.
  • Confused about how style sheet inheritance works

    Unsolved Qt WebKit qt 4.8 qwebview stylesheet css
    5
    0 Votes
    5 Posts
    2k Views
    KillerSmathK
    @define-qt You can be more specific using the name of object as identifier in style sheet sintaxe QLineEdit#ObjectName { border:0; }
  • CSS: dynamic properties and (pseudo) states

    Unsolved General and Desktop css properties states
    1
    0 Votes
    1 Posts
    686 Views
    No one has replied
  • Customizing QMainWindow by style sheet

    Solved General and Desktop stylesheet qt5.8 css qmainwindow
    5
    0 Votes
    5 Posts
    14k Views
    M
    @eDeviser said in Customizing QMainWindow by style sheet: Yes, this helps! I see the QMainWindow holds a QWidget which is set as cetralWidget. So It would be necessary to set the QMainWindow as centralWidget or to apply my css for the QWidget. [image: 5e12e54b-0473-4242-b177-1c26364b1191.png] Thank you for this hint. You have to apply your css in your qwidget ! Your css should be : centralWidget { background: yellow; width: 10px; /* when vertical / height: 10px; / when horizontal */ } centralWidget:hover { background: red; }
  • Can we use CSS on QPushButton

    Unsolved General and Desktop stylesheet qt 5.7 css
    6
    0 Votes
    6 Posts
    9k Views
    IMAN4KI
    @Swapnil_Shelke To create those kind of buttons you need more than CSS. You must go into button's paintEvent and then draw what you need (there are 3 simultaneous animation BTW) : #include <QtCore/qvariantanimation.h> #include <QtCore/qvariant.h> #include <QtWidgets/qabstractbutton.h> #include <QtWidgets/qapplication.h> #include <QtWidgets/qlayout.h> class Animation : public QVariantAnimation { Q_OBJECT public: Animation(QObject *parent = 0) :QVariantAnimation(parent) { setTargetWidget(qobject_cast<QWidget*>(parent)); setAutoUpdateEnable(true); } void setAutoUpdateEnable(bool a) { if (targetWidget()) { a ? QObject::connect(this, SIGNAL(valueChanged(QVariant)), targetWidget(), SLOT(update())) : QObject::disconnect(this, SIGNAL(valueChanged(QVariant)), targetWidget(), SLOT(update())); } } QWidget *targetWidget() const { return _target; } void setTargetWidget(QWidget *w) { _target = w; } QVariant value() const { return _value; } void setValue(const QVariant &variant) { if (_value == variant) return; _value = variant; } protected: void updateCurrentValue(const QVariant &value) override { setValue(value); } private: QVariant _value; QWidget *_target = nullptr; }; class SampleButton :public QAbstractButton { public: struct ButtonStyle { qreal border_radius = 4.0; QColor background_color = QColor("#f4511e"); QColor text_color = QColor("#ffffff"); int font_size = 28; QString font_family = "Arial"; int width = 200; int padding = 20; qreal hover_padding = 25; int duration = 600; QIcon icon = QIcon("next.png"); // http://www.flaticon.com/free-icon/double-angle-pointing-to-right_25358 @16x16 qreal pixmap_padding = 20; }; SampleButton(const QString &text, QWidget *parent = 0) :QAbstractButton(parent), _textEff(new Animation(this)), _pixmapEff0(new Animation(this)), _pixmapEff1(new Animation(this)) { setFont(QFont(_st.font_family, _st.font_size)); setText(text); } QSize sizeHint() const override { return QSize(_st.width, _st.padding + fontMetrics().height() + _st.padding); } protected: void paintEvent(QPaintEvent *) override { QPainter p(this); // draw background p.setPen(Qt::NoPen); p.setBrush(_st.background_color); p.setRenderHint(QPainter::Antialiasing, true); p.drawRoundedRect(rect(), _st.border_radius, _st.border_radius); p.setRenderHint(QPainter::Antialiasing, false); // draw text if (!text().isEmpty()) { p.setFont(font()); p.setPen(_st.text_color); p.setRenderHint(QPainter::TextAntialiasing, true); p.drawText(QRectF(rect().x() - _textEff->value().toReal(), rect().y(), rect().width(), rect().height()), Qt::AlignCenter, text()); p.setRenderHint(QPainter::TextAntialiasing, false); } // draw icon if (!_st.icon.isNull()) { p.setRenderHint(QPainter::SmoothPixmapTransform, true); auto s = _st.icon.availableSizes().at(0); p.setOpacity(_pixmapEff0->value().toReal()); p.drawPixmap(QPointF(rect().right() - (_st.pixmap_padding * 2) - _pixmapEff1->value().toReal(), rect().center().y() - s.width() / 4), _st.icon.pixmap(s)); } } void enterEvent(QEvent *e) { _textEff->setStartValue(0.0); _textEff->setEndValue(_st.hover_padding); _textEff->setDuration(_st.duration); _textEff->setEasingCurve(QEasingCurve::OutCubic); _textEff->start(); _pixmapEff0->setStartValue(0.0); _pixmapEff0->setEndValue(1.0); _pixmapEff0->setDuration(_st.duration); _pixmapEff0->setEasingCurve(_textEff->easingCurve()); _pixmapEff0->start(); _pixmapEff1->setStartValue(0.0); _pixmapEff1->setEndValue(_st.pixmap_padding); _pixmapEff1->setDuration(_st.duration); _pixmapEff1->setEasingCurve(_textEff->easingCurve()); _pixmapEff1->start(); QWidget::enterEvent(e); } void leaveEvent(QEvent *e) { _textEff->setStartValue(_st.hover_padding); _textEff->setEndValue(0.0); _textEff->setDuration(_st.duration); _textEff->start(); _pixmapEff0->setStartValue(1.0); _pixmapEff0->setEndValue(0.0); _pixmapEff0->setDuration(_st.duration); _pixmapEff0->start(); _pixmapEff1->setStartValue(_st.pixmap_padding); _pixmapEff1->setEndValue(0.0); _pixmapEff1->setDuration(_st.duration); _pixmapEff1->setEasingCurve(_textEff->easingCurve()); _pixmapEff1->start(); QWidget::leaveEvent(e); } private: ButtonStyle _st; Animation *_textEff = nullptr; Animation *_pixmapEff0 = nullptr; Animation *_pixmapEff1 = nullptr; }; int main(int argc, char *argv[]) { QApplication app(argc, argv); QWidget *dialog = new QWidget; dialog->setWindowFlags(Qt::FramelessWindowHint); QHBoxLayout _Layout; dialog->setLayout(&_Layout); SampleButton *sb = new SampleButton("Hover"); _Layout.addWidget(sb); dialog->show(); return app.exec(); } #include "main.moc" [image: Kgjed.gif]
  • 0 Votes
    6 Posts
    7k Views
    J.HilkJ
    You can define an accessibleName for your objects and distribute different StyleSheets. either via the designer or QWidget::setAccessibleName(const QString &name); e.g. QPushButton{ background-color: blue; } QPushButton[accessibleName="SpecialButton1"] { background-color: red; }
  • 0 Votes
    9 Posts
    5k Views
    mrjjM
    @Romain-C Well it still confused me sometimes :)
  • QComboBox with transparent dropdown

    Unsolved General and Desktop qt5 qcombobox stylesheet drop-down css
    5
    0 Votes
    5 Posts
    5k Views
    S
    @VRonin With the provided code the whole dropdown list will be invisible. Do you know how to keep the items unaffected?
  • Using Qt private CSS parser

    Solved General and Desktop css parser qcssparser qt5
    12
    0 Votes
    12 Posts
    3k Views
    IMAN4KI
    @Devopia53 Excellent answer :) Not recommended... Yeah know it and i make these files local in my project (not include from <private/qcssparser_p.h>): qcssscanner.cpp qcssparser_p.h qcssparser.cpp Thank you
  • 0 Votes
    14 Posts
    3k Views
    IMAN4KI
    @raven-worx Oh.. Sorry i think that was qt-bug (getter return invalid) but now it's work For last question ! Could i use qcssparser_p.h for retrieving values for my purpose ? (i'm a lover of parsing :) ) Thanks.