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. [SOLVED] QStyleOptionViewItem draw text ?
Qt 6.11 is out! See what's new in the release blog

[SOLVED] QStyleOptionViewItem draw text ?

Scheduled Pinned Locked Moved General and Desktop
17 Posts 3 Posters 9.5k 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.
  • raven-worxR Offline
    raven-worxR Offline
    raven-worx
    Moderators
    wrote on last edited by
    #5

    what exactly do you mean?

    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
    If you have a question please use the forum so others can benefit from the solution in the future

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Sam
      wrote on last edited by
      #6

      Ok i'll explain in detail,

      The background color(yellow/red) of the lineEdit changes based on the validator and the current text. The tableview cell should render the same palette/effect of the lineEdit.

      The lineEdit is initialized/editable when a particular cell is clicked. I need to set the same effect for a particular cell. For the tableView each cell contains an object of a class that stores the property like text/palette etc.

      Eg I need to render something like

      !http://img42.imageshack.us/img42/3738/v3c4.png(lineEdit)!

      1 Reply Last reply
      0
      • raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #7

        ok, but why do you want to draw a line edit instead of using a real qlinedit widget?
        pro: works our of the box like a qlineedit should
        con: may cause performance

        Or why do you want to draw a QLineEdit widget at all and not just simply the text with a background color?

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Sam
          wrote on last edited by
          #8

          [quote author="raven-worx" date="1371554769"]ok, but why do you want to draw a line edit instead of using a real qlinedit widget?
          pro: works our of the box like a qlineedit should
          con: may cause performance
          [/quote]

          I can't use setInexWidget() performance drops heavily !!!

          bq. Or why do you want to use a QLineEdit widget at all?

          The lineEdit is initialized in the createEditor(). what else you recommend ?

          1 Reply Last reply
          0
          • raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by
            #9

            just draw the text with a simple background is enough for you?

            How do you exactly change the background color of the line edit when the QValidator fails? By Stylesheet?

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0
            • S Offline
              S Offline
              Sam
              wrote on last edited by
              #10

              yes the background color for the lineEdit changes through styleSheets.
              Yes easiest way is to change the background color of the cell.

              Thanks :)

              PS : I was thinking too complex :)

              1 Reply Last reply
              0
              • raven-worxR Offline
                raven-worxR Offline
                raven-worx
                Moderators
                wrote on last edited by
                #11

                thats why i asked ;)

                --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                If you have a question please use the forum so others can benefit from the solution in the future

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  Sam
                  wrote on last edited by
                  #12

                  One more question I would like to ask , is there anyway we can get the background-color of the lineEdit which is set through stylesheets like in the above image the yellow color is set through stylesheet.

                  Anything like
                  lineEdit->palette().color(QPalette::?????);

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    andre
                    wrote on last edited by
                    #13

                    No. It might not even be a color. It might be a brush. Or an image, or...

                    1 Reply Last reply
                    0
                    • raven-worxR Offline
                      raven-worxR Offline
                      raven-worx
                      Moderators
                      wrote on last edited by
                      #14

                      try QPalette::Background

                      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                      If you have a question please use the forum so others can benefit from the solution in the future

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        Sam
                        wrote on last edited by
                        #15

                        and if we are setting the background-color through stylesheets then also its not possible to retrieve the value ?

                        PS : QPalette::Background return gray color

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          andre
                          wrote on last edited by
                          #16

                          [quote author="Sam" date="1371730152"]and if we are setting the background-color through stylesheets then also its not possible to retrieve the value ?[/quote]
                          AFAIK: indeed not. The style sheets are not exposed through the public API other then setting them on a widget or the application.

                          I'd love to be proven wrong on this one though!

                          1 Reply Last reply
                          0
                          • S Offline
                            S Offline
                            Sam
                            wrote on last edited by
                            #17

                            Thanks Andre,

                            I think then I have to check/set the color for the painter based on properties specified for the lineEdit.

                            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