Skip to content
QtWS25 Last Chance
  • I ran into a strange problem with QStyle.

    Unsolved General and Desktop qt5 c++17 qstyle qstylesheet
    4
    0 Votes
    4 Posts
    404 Views
    Christian EhrlicherC
    Please provide a minimal, compilable example of your problem. Check it with a recent Qt6 version and if the issue still exists, create a bug report (or post it here and I'll take a look on it).
  • 0 Votes
    4 Posts
    439 Views
    SGaistS
    Looks like you may have unearthed a bug. You should check the bug report system to see if there's something already about it and if not please open a new ticket providing your findings.
  • Frame color/palette of QGroupBox?

    Unsolved General and Desktop qpalette qgroupbox qstyle qproxystyle
    2
    0 Votes
    2 Posts
    685 Views
    Chris KawaC
    Fusion style ignores palette for the groupbox frame and uses a hardcoded semi-transparent pixmap. See the source.
  • 0 Votes
    3 Posts
    1k Views
    D
    @mrjj I'm using aliases, but your code does not specivy hover action ? Darn sorry, I didnt specify question well :/ I cant change hover action. Not icon itself. QDockWidget::float-button:hover does not quite work. Also any idea where I can find other "button types?" Maximize, Minimize, etc etc?
  • Styling all of QtreeView...

    Unsolved General and Desktop qstyle qproxystyle qstylesheet qtreeview qwidget
    3
    0 Votes
    3 Posts
    828 Views
    D
    @VRonin I want to do some heavy changes/customisations... stuff I cant do in CSS... Like moving expand button to opposite of tree, changing location of checkbox, changing indentation of child items. How can I control indentation of child items? I need it now :/ I keep getting "invisible" hitboxes as my child item is moved to left visually but hitboxes are drawn in original places :/// Ideas? I just realized there is "setIndentation"... sigh............ Ok that kinda works, how can I set indentation per row? :D
  • 0 Votes
    7 Posts
    1k Views
    D
    I finally got it solved... The fix was: QPushButton { width: 100%; } :- )
  • How to get this style on a button

    Unsolved General and Desktop qstyle qstylesheet fusion
    10
    0 Votes
    10 Posts
    2k Views
    L
    @Dariusz said in How to get this style on a button: @JKSH AH yes, could do... but I'm trying to css entire app with hundreds of buttons/etc.. I think you could inherit from the QPushButton then: class MyButton : public QPushButton { MyButton( ... ) : ... { setMinimumSize( ... ); } };
  • 0 Votes
    5 Posts
    730 Views
    B
    @mrjj I have the following stylesheet applied to a containing widget QMenu, QMenu QPushButton { background-color: #303030; color: white } When I remove the QMenu selector, the white line disappears (hence it starts looking like this) [image: 5a161ee4-3e8d-419a-8680-e774d2c01e70.png] I cannot say whether the white line really disappears or it just blends with the white color of the menu item. After applying the same style with a QMenu::item selector, I get the following: [image: 134815d0-278a-4a93-af33-bbdd63c68ea2.png] The ordinary menu items are colored, but those created by my class are not. It appears as if the ::menuItem selector does not work on them. I also tried setting the following style rule on the container returned by the createWidget function container->setStyleSheet(".MenuItem {background-color: #303030; color: white; }"); and it oddly makes the custom menu items get shifted to the left and the hover effects on them do not seem to work any longer. Applying padding/margin does not fix it: [image: e5b252c8-4e60-4a32-b13e-794608842129.png]
  • How to set QStyle::SH_ComboBox_Popup to false?

    Unsolved General and Desktop qstyle combobox fusion
    6
    0 Votes
    6 Posts
    990 Views
    CJhaC
    @raven-worx For me, it seems as it is working. The above code is actually taken from ProxyStyle web page from Qt's website, I just replaced QStyle::SH_UnderlineShortcut with QStyle::SH_ComboBox_Popup. So, I think it is a good approach. Subclassing QComboBox would become quite cumbersome as I will have to promote all the combo boxes in my UI to the subclass.
  • Where is QLineEdit's text drawn in QStyle?

    Unsolved General and Desktop qpalette qstyle
    3
    0 Votes
    3 Posts
    685 Views
    CJhaC
    @mrjj Thanks, it seems like odd behaviour. So, it uses its native palette, i.e. the palette set either directly or inherited from its parent. I am able to change the colour now, but I am using a C-Style cast, and that's why I am not sure if I should do it. Here is my solution: void GuiStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget) const { if(vars[id].customTheme) { if(element == QStyle::PE_PanelLineEdit) { const QStyleOptionFrame* comboOption = qstyleoption_cast<const QStyleOptionFrame*>(option); QStyleOptionFrame newComboOption = *comboOption; newComboOption.palette.setBrush(QPalette::Base, Qt::red); // I am using C-Style cast to get the widget in a non-const pointer and then it's palette again the same way QLineEdit* lineEditPtr = (QLineEdit*)widget; QPalette pal = (QPalette)lineEditPtr->palette(); pal.setColor(QPalette::Text, Qt::green); lineEditPtr->setPalette(pal); QProxyStyle::drawPrimitive(element, &newComboOption, painter, widget); } } else { QProxyStyle::drawPrimitive(element, option, painter, widget); } }
  • Change property of a class during runtime

    Unsolved General and Desktop qstyle qspinbox
    1
    0 Votes
    1 Posts
    223 Views
    No one has replied
  • 0 Votes
    1 Posts
    242 Views
    No one has replied
  • Qt6 QProxyStyle cause app crash

    Unsolved General and Desktop qproxystyle qstyle qapplication
    17
    0 Votes
    17 Posts
    2k Views
    Christian EhrlicherC
    Sorry but I still don't see why you need to delete and re-create the proxy style. But do what you like.
  • 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 ?
  • QTreeView branch drawing... missing branch?

    Unsolved General and Desktop qtreeview qstyle
    5
    0 Votes
    5 Posts
    2k Views
    SGaistS
    In fact, it's the QTreeView::drawBranch that handles that.
  • 0 Votes
    3 Posts
    1k Views
    G
    @Gojir4 said in Styling the QMdiArea using the the fusion style and QPalette (dark theme): darkPalette.setColor(QPalette::Disabled, QPalette::Shadow, QColor(r, g, b)); (Edited) tried, but it didn't work. I suspect that underneath it's a QLabel with a raised text but I don't know how to set the color of those using QPalette
  • Difficulty displaying icons in widgets

    Unsolved General and Desktop qstyle generatedicon qiconnormal
    5
    0 Votes
    5 Posts
    1k Views
    O
    @SGaist The project consists of three cpp and two header files. The code of cpp files is listed below: myapp.cpp #include "myapp.h" myApp::myApp(QWidget *parent) : QMainWindow(parent) { QIcon icns(":/03_Images/simple_icon.png"); QPushButton* btnNormal = new QPushButton(this); btnNormal->setText("Normal"); btnNormal->setIcon(icns); QPushButton* btnActive = new QPushButton(this); btnActive->setText("Active"); btnActive->setIcon(icns); QPushButton* btnDisabled = new QPushButton(this); btnDisabled->setText("Disabled"); btnDisabled->setIcon(icns); btnDisabled->setEnabled(false); QHBoxLayout* layout = new QHBoxLayout(); layout->addWidget(btnNormal); layout->addWidget(btnActive); layout->addWidget(btnDisabled); QWidget* centralWidget = new QWidget(this); centralWidget->setLayout(layout); setCentralWidget(centralWidget); QMenu* menu = new QMenu(this); menu->setTitle("Menu"); QAction* actItem4_1 = menu -> addAction("Normal icon", this, SLOT(repaint())); actItem4_1 ->setIcon(icns); QAction* actItem4_2 = menu -> addAction("Active icon", this, SLOT(repaint())); actItem4_2 ->setIcon(icns); QAction* actItem4_3 = menu -> addAction("Disabled icon", this, SLOT(repaint())); actItem4_3 ->setIcon(icns); actItem4_3 ->setEnabled(false); QMenuBar* menuBar = new QMenuBar(this); menuBar->addMenu(menu); setMenuBar(menuBar); } mystyle.cpp #include "mystyle.h" MyStyle::MyStyle() : QProxyStyle(QStyleFactory::create("fusion")){ setObjectName("MyStyle"); } MyStyle::~MyStyle(){ // } void MyStyle::polish(QPalette& palette){ palette.setColor(QPalette::Window, QColor(230, 230, 230)); palette.setColor(QPalette::WindowText, QColor(64, 64, 64)); palette.setColor(QPalette::Base, QColor(248, 248, 248)); palette.setColor(QPalette::AlternateBase, QColor(243, 243, 243)); palette.setColor(QPalette::Text, QColor(64, 64, 64)); palette.setColor(QPalette::ToolTipBase, QColor(0, 255, 0)); palette.setColor(QPalette::ToolTipText, QColor(64, 64, 64)); palette.setColor(QPalette::Button, QColor(194, 194, 194)); palette.setColor(QPalette::ButtonText, QColor(64, 64, 64)); palette.setColor(QPalette::BrightText, QColor(0, 255, 0)); palette.setColor(QPalette::Highlight, QColor(86, 86, 86)); palette.setColor(QPalette::HighlightedText, QColor(191, 191, 191)); palette.setColor(QPalette::Disabled, QPalette::WindowText, QColor(128, 128, 128)); palette.setColor(QPalette::Disabled, QPalette::Button, QColor(214, 214, 214)); palette.setColor(QPalette::Disabled, QPalette::ButtonText, QColor(127, 127, 127)); palette.setColor(QPalette::Disabled, QPalette::Text, QColor(128, 128, 128)); palette.setColor(QPalette::Disabled, QPalette::HighlightedText, QColor(64, 128, 0)); } QPixmap MyStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const { QImage img = pixmap.toImage().convertToFormat(QImage::Format_ARGB32); QPainter painter(&img); painter.save(); switch (iconMode) { case QIcon::Normal: qDebug() << "Normal mode"; painter.fillRect(img.rect(), QColor(Qt::red)); break; case QIcon::Active: qDebug() << "Active mode"; painter.fillRect(img.rect(), QColor(Qt::green)); break; case QIcon::Disabled: qDebug() << "Disabled mode"; painter.fillRect(img.rect(), QColor(Qt::blue)); break; case QIcon::Selected: qDebug() << "Selected mode"; painter.fillRect(img.rect(), QColor(Qt::magenta)); break; default: qDebug() << "Other mode (Unknown)"; painter.fillRect(img.rect(), QColor(Qt::gray)); break; } painter.restore(); return QPixmap::fromImage(img); } main.cpp #include "myapp.h" #include <QApplication> #include "mystyle.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); a.setStyle(new MyStyle()); myApp w; w.show(); return a.exec(); }
  • 0 Votes
    11 Posts
    3k Views
    Y
    @SGaist got it.
  • Custom style QSlider problem

    Unsolved General and Desktop qstyle qslider qcommonstyle
    1
    0 Votes
    1 Posts
    866 Views
    No one has replied