Page 2 of 2 FirstFirst 12
Results 21 to 25 of 25

Thread: Color a row - QSqlRelationalTableModel or QSqlQueryModel

  1. #21
    Join Date
    Sep 2016
    Posts
    12
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Color a row - QSqlRelationalTableModel or QSqlQueryModel

    I'm quoting you now as you keep changing your messages... after i reply, making me confused.

    Quote Originally Posted by jefftee View Post
    I have reread my post and I don't believe that I insinuated or assumed that you are stupid. I just find it astonishing that you ask for people to write code for you and then point out a simple mistake in a code example which I clearly stated was not tested or compiled. How about you test the various code samples people gave you and determine which is fastest or write yourself from scratch rather than demand that someone tell you which is fastest? Learn how to help yourself and you will be much better off in the long run, I promise.

    Regarding why the QVariant was not const, try to make it const and compile the sample I gave you and the answer will become obvious.

    You insist that performance is the only thing that matters and you fret over which trivial versions of code multiple people have voluntarily given to you is most efficient. You admitted that you will be "adding a lot of things to this data function". Don't you think that the "lot of things" you will be adding may perhaps have a more relevant impact to performance than the trivial examples you were given?

    Clearly I don't think I can help you, but my advice to you remains the same. Stop the analysis paralysis and move on to writing the "lot of things" that you need to add to the data method.

    Good luck!
    It is ok that you assume that another person has a typo, or that you assume he pasted the wrong text and pointing that out, but you are insinuating stupidity or some type of lack of capacity.... and you are on it again now... insinuating that I am demanding, and that i am somehow bothering people refusing to make my own effort.

    anda_skoa pointed out many things that is wrong about the code, what the things are and things that should not be int he code etc. and it is clearly just fine to point out "stupid code" but you are not addressing the code but the coder... when you talk about what is wrong.

    I am done with this topic, you are welcome to not replying any more of my messages, because you make me feel bad, and ruin my fun.
    Last edited by AKG; 9th September 2016 at 06:54.

  2. #22
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: Color a row - QSqlRelationalTableModel or QSqlQueryModel

    Quote Originally Posted by AKG View Post
    It is ok that you assume that another person has a typo, or that you assume he pasted the wrong text and pointing that out, but you are insinuating stupidity or some type of lack of capacity.... and you are on it again now... insinuating that I am demanding, and that i am somehow bothering people refusing to make my own effort.
    Sorry that you feel I have attacked you (again). I only post here to try to help others. I am certainly not the brightest or best coder here, but I *have* been able to help many people.

    I hope you are familiar with the proverb "Give a man a fish and he'll eat for a day, teach a man to fish and he will eat for a lifetime". That is how I prefer to try to help people, by pointing them in the right direction so that they can learn how to problem solve on their own. One of the best skills you will ever learn as a programmer is how to problem solve. When you ask for code for the data method or ask which version of the code is the fastest, you are asking for a fish. If someone here gives you that fish, you will have learned nothing.

    I gave you an example of a bare bones data method that met your requirement for changing the background color to yellow if column 2 was an empty string, as did several others. When you asked which is fastest of the several examples you were given, I recommended that you test each one and make that determination on your own.

    To get you started how to do that, one possible method would be to use QTime::start and QTime::elapsed to calculate the elapsed time between the entry/exit into the data method and output those timings using qDebug so that you can evaluate the elapsed time of each. As you add the "lots of things" functionality into the data method, you can do the same to determine where your data method is spending its time, etc.

    A more advanced approach would be to profile your application using an tool like valgrind or similar.

    No need to respond to my post, I have done what I can to help until you have demonstrated that you've done what I have suggested and have additional questions. You may also completely ignore my advice and maybe someone will give you the fish, but it won't be me.

    Whether you believe me or not, I do hope you accomplish your objective.

    Good luck!
    I write the best type of code possible, code that I want to write, not code that someone tells me to write!

  3. #23
    Join Date
    Sep 2016
    Posts
    12
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Color a row - QSqlRelationalTableModel or QSqlQueryModel

    When the compiler sees == on a string, at the same time that we are evaluating the other values, what is all that happens ? and how expensive is that compared to for example the other suggestion where it is using the .isEmpty() ?? What is happening inside isEmpty() ?? is it more expensive or is there something to gain ?

    I know you are not interested in answering my questions and that is totally fine, I'm not interested in hearing abut fish anyway ;-)

    Now after your insinuations you are clearly starting to parent me on how i should go about learning programming .... just give it a rest already mr America :-) no nead to save the entire world all by yourself.

  4. #24
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Color a row - QSqlRelationalTableModel or QSqlQueryModel

    Quote Originally Posted by AKG View Post
    When the compiler sees == on a string, at the same time that we are evaluating the other values, what is all that happens ? and how expensive is that compared to for example the other suggestion where it is using the .isEmpty() ?? What is happening inside isEmpty() ?? is it more expensive or is there something to gain ?
    isEmpty() is almost certainly faster since the expected value is either a null string or a non-empty string.
    But that was one of my original points, wasn't it?

    In any case it really doesn't matter, only actually measured timing data does.

    The only thing that is always true is that things that are not executed are "faster" than things that are executed, so doing things that aren't necessary is always going to be more time consuming than not doing it in the first place.
    Which of course is also one of the initially pointed out issues.

    Cheers,
    _

  5. #25
    Join Date
    Sep 2016
    Posts
    12
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Color a row - QSqlRelationalTableModel or QSqlQueryModel

    The reason I was repeating this question, was to explain to the other poster jefftee what my question were actually about.

    I'm sorry that it sounded like i did not already get it, because you did point it out very well already, and I really appreciate your comment i previous posts. You already explained it very well, and I really appreciate your previous answers. Sorry for the repeated question. That was intended for the other poster to make him understand what my question was before. But it is already answered, you are absolutely correct about that.

    Thank you /

Similar Threads

  1. Replies: 3
    Last Post: 3rd February 2014, 17:04
  2. Replies: 0
    Last Post: 10th September 2013, 11:05
  3. Replies: 4
    Last Post: 8th September 2011, 08:22
  4. Replies: 3
    Last Post: 22nd January 2010, 16:46
  5. Display Label Color by selecting Color Picker
    By sosanjay in forum Qt Programming
    Replies: 1
    Last Post: 25th September 2009, 06:11

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.