Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. G++ would not allow this, take a look before it drives you nuts (example with QPalette)
Forum Updated to NodeBB v4.3 + New Features

G++ would not allow this, take a look before it drives you nuts (example with QPalette)

Scheduled Pinned Locked Moved C++ Gurus
26 Posts 8 Posters 12.1k 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.
  • D Offline
    D Offline
    dangelog
    wrote on last edited by
    #17

    [quote author="Quicksort" date="1317685193"]With a single call, without all this fuss, Mr Specialist.
    Got it ?[/quote]

    It's nonsense to use that attitude. Write an inline function so you can modify your palette with a single line of code.

    Software Engineer
    KDAB (UK) Ltd., a KDAB Group company

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #18

      [quote author="Quicksort" date="1317685193"]With a single call, without all this fuss, Mr Specialist.
      Got it ?[/quote]

      Please calm down your wording. People are trying to explain things to you. There is absolutely no reason to become personally insulting.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tobias.hunger
        wrote on last edited by
        #19

        Why are you claiming this is a g++ issue?

        I would be surprised if other compilers did not issue a similar error: Modifying a const reference is wrong.

        Your "fix" by forcing it to be non-const is rather questionable though: It might or might not work, depending on how the widget is implemented, ruining the encapsulation OO design is all about.

        1 Reply Last reply
        0
        • ? This user is from outside of this forum
          ? This user is from outside of this forum
          Guest
          wrote on last edited by
          #20

          ->Franzk:

          As for my inappropriate tone, let me tell you I am a bit tired of the patronizing
          one of the forum' s divas. Now, I just suggested to add a few QWidget
          functions allowing in one programming step to modify some palette settings.
          It would translate in several function calls behind the scenes but would ease
          programmer' s task.

          ->Andre:

          I have clearly stated that the label is not yet visible when this palette setting
          is modified. Since you have established it does not work if the widget is
          already visible, your method is clearly the right one although it remains
          quite contrived due to the lack of QWidget functions doing the job in one
          programming step.

          ->Others:

          Nothing.

          1 Reply Last reply
          0
          • L Offline
            L Offline
            lgeyer
            wrote on last edited by
            #21

            You gave an opinion, someone else gave an opinion - so what's all this frenzy about here?
            You decided to post on a public forum, so

            • you should be able to ignore or report posts you find improper or
            • you should not post on public forums

            There is a broad consensuns here at the QDN that rude behaviour and personal insults are not tolerated. Period.

            As to your initial post: The compiler warning has been surpressed by an explicit cast. This is the behaviour I would expect. There is a reason const casts should be rarely used.

            As to your suggestion: Rejected. The API already provides the requested functionality and the saving of two lines of code (at best) does not justify this redundancy. This would violate Qts API design principles. As already suggested I would create an inline function.

            However, feel free to add the requested functionality and submit a merge request. This is how such discussions are usually solved here.

            1 Reply Last reply
            0
            • ? This user is from outside of this forum
              ? This user is from outside of this forum
              Guest
              wrote on last edited by
              #22

              ->Volker
              -> Lukas Geyer

              Insults ? For a "Got it ?".
              Our defintions of this word must be very different.
              As for my "rude" behaviour, to quote you Mr Geyer,
              it was triggered by the patronizing tone of most
              answers to my posts. However I must admit your
              last reply' s technical remarks (const_cast and API
              design principles)make perfect sense.

              I just had a peek at your profile:
              Congratulaions for having, and for so long, contributed
              to such a great toolkit.

              1 Reply Last reply
              0
              • ? This user is from outside of this forum
                ? This user is from outside of this forum
                Guest
                wrote on last edited by
                #23

                ->peppe

                Sorry for my unbecoming remark.

                -> Tobias Hunger (with some delay)

                Mr Hunger,

                I a am an Assembly language x64, APL and C programmer
                but a newcomer to C++ and its design philosophy.
                As for GUI toolkits, the only one I knew about was GTK +.
                I dropped it because of its implementation of signals I don' t
                like, to the say the least.
                So, I was very surprised by g++ (legitimate) reaction
                to my attempt to call setColor through a constant reference
                to a QPalette. Realizing shortly after that it made sense but
                considering I had the "right" to cast this thing. Well, since
                g++ stopped complaining I thought it might be appropriate
                to inform those likely to run across the same kind of problem
                that my trick worked. It was my sole purpose. Now, it does
                infringe QT design philosophy as you and Mr Geyer, among
                others, pointed out.

                Congratulations for your continuing contribution to Qt.

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mgran
                  wrote on last edited by
                  #24

                  Just (pa)trolling past this thread and it's encouraging to see that things are sort of sorted :)

                  Project Manager - Qt Development Frameworks

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    goetz
                    wrote on last edited by
                    #25

                    Hi Quicksort,

                    [quote author="Quicksort" date="1317767499"]
                    I a am an Assembly language x64, APL and C programmer
                    but a newcomer to C++ and its design philosophy.
                    [/quote]

                    that's an important information which will put your first post in a completely different context. I'm pretty sure, everyone here thought you were quite familiar with C++ and the concepts. So some of the answers could have looked a bit weird to you.

                    Anyways, if you want to read some good stuff on C++ features, I can recommend you the "C++ FAQs":http://www.parashift.com/c++-faq-lite - it's always a good inspiration. Not to forget to leave behind many of the concepts of assembly language or C (including casts!) when switching to C++ :-)

                    http://www.catb.org/~esr/faqs/smart-questions.html

                    1 Reply Last reply
                    0
                    • ? This user is from outside of this forum
                      ? This user is from outside of this forum
                      Guest
                      wrote on last edited by
                      #26

                      Thank you for your friendly post, Volker.
                      I will take a close look at these FAQs, I have a lot to learn...
                      Now, you might be, the case being, interested in Dr Agner Fog' s
                      manual about C++ optimization (from a programmer viewpoint,
                      it' s not about compiler writing).
                      I encourage everyone to visit his great website http://www.agner.org/.
                      You will find there various manuals and (free) software packages.
                      This man has an incredible knowledge of microprocessor architectures
                      and assembly language optimization. I owe him so much.

                      Cheers.

                      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