Skip to content
QtWS25 Call for Papers
  • 0 Votes
    4 Posts
    212 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.

  • 0 Votes
    2 Posts
    407 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
    763 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?

  • 0 Votes
    3 Posts
    426 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
    581 Views
    D

    I finally got it solved...

    The fix was:

    QPushButton { width: 100%; }

    :- )

  • 0 Votes
    10 Posts
    1k 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
    424 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)
    10a42cae-0e1b-4d97-88b6-eacbaec7e038-image.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:
    5ffa874d-36f1-4742-a31a-078469ec6e2f-image.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:

    4132b0aa-b742-4af9-aa91-eeeb961b6aab-image.png

  • 0 Votes
    6 Posts
    506 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.

  • 0 Votes
    3 Posts
    386 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); } }
  • 0 Votes
    1 Posts
    149 Views
    No one has replied
  • 0 Votes
    1 Posts
    159 Views
    No one has replied
  • 0 Votes
    17 Posts
    1k 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.

  • 0 Votes
    8 Posts
    1k 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 ?

  • 0 Votes
    5 Posts
    1k 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

  • 0 Votes
    5 Posts
    790 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
    2k Views
    Y

    @SGaist got it.

  • 0 Votes
    1 Posts
    772 Views
    No one has replied