Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Setting CSS style through web pages and QWidgets
Forum Updated to NodeBB v4.3 + New Features

Setting CSS style through web pages and QWidgets

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AlexMagalhaes
    wrote on last edited by
    #1

    Hi everyone,

    I'm creating a Qt application with some web pages loaded on QWebViews and also some plain QWidgets, all inside a QMainWindow. Both the webpages and widgets are going to have some checkboxes here and there, and I'd like them to look the same. Well, at first they DO look the same, because they inherit their style from the native theme engine, but I'd like to define a new CSS style for both.

    I tried some things like

    @QCheckBox::indicator:unchecked {
    image: url(:/image/checkbox_unchecked.png);
    }@

    but that only works for checkboxes inside my QWidgets.

    I also tried some plain CSS style, but then they only apply to webpage checkboxes.

    So, is there a way I could design a single CSS style for checkboxes and apply it to all sorts of checkboxes inside my application?

    For the record, I could achieve that when it comes to text selection. I set the main window stylesheet to

    @selection-color: #363636; selection-background-color: #bfebeb;@

    and both web page and qwidget selections followed this style.

    1 Reply Last reply
    0
    • B Offline
      B Offline
      b1gsnak3
      wrote on last edited by
      #2

      Well you should apply qss and plain css... You cannot apply just one for both... At least not that I know of...

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Thuthuka
        wrote on last edited by
        #3

        check out
        http://qt-project.org/doc/qt-4.8/stylesheet-examples.html#customizing-qcheckbox

        you will need something along the lines of this

        ui->checkBox->setStyleSheet("QCheckBox{ spacing: 10 }\n"
                                    "QCheckBox::indicator:checked:hover{image: url(:/images/checkbox_checked_hover.png);}\n"
                                    "QCheckBox::indicator:checked:pressed{image: url(:/images/checkbox_checked_pressed.png);}");
        
        1 Reply Last reply
        0
        • B Offline
          B Offline
          b1gsnak3
          wrote on last edited by
          #4

          @Thuthuka he said he managed to set stylesheet for QCheckbox... His problem is how to set one CSS code for both QCheckBox and the Web CheckBoxes...

          1 Reply Last reply
          0
          • A Offline
            A Offline
            AlexMagalhaes
            wrote on last edited by
            #5

            Exactly. I thought it was possible since I achieved that for text selection, using

            @*{
            selection-color: #363636; selection-background-color: #bfebeb;
            }@

            as I said before.

            Anyone?

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved