Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show classnames next to objectNames, when different #865

Merged
merged 1 commit into from
Nov 29, 2023

Conversation

dfaure-kdab
Copy link
Member

Property | Value | Type | Class
Before:
parent | m_loadingWidget | QObject* | QObject
After:
parent | m_loadingWidget (QSvgWidget) | QObject* | QObject

Should this be QSvgWidget* with a star?
Or something more consistent with the case where there's no objectName, which shows "QFrame[this=0xdcd22e0]" ?

The change propagated to other classes to fix const [in]correctness (the const_cast is only because of QHash API, it shouldn't be necessary for the caller of those methods).

@Waqar144
Copy link
Contributor

Should this be QSvgWidget* with a star?

I would prefer this as its slightly more accurate.

For the case where we don't have objectName, I think show QFrame[this=0xdcd22e0] is a good idea and is consistent with some other places.

@dfaure-kdab
Copy link
Member Author

dfaure-kdab commented Nov 13, 2023

QFrame[this=0xdcd22e0] is already implemented, I was only mentioning it because there's some inconsistency between objectName(className) and className[this=value]
The className is in parenthesis in one, outside everything in the other, and the pointer value is only shown in the case without an object name. So I was wondering if we should unify this somehow....
Maybe it could be className[objectName, this=value] ? I'm not 100% sure, because the object name might be the main thing we want to see.

Brainstorming other solutions: [this=value](className) and objectName[this=value](className)?

About QSvgWidget * I'm also hesitant. In my example above, it's indeed a property that is a raw pointer. But we're in the code that prints information about an object, we don't know what the property in the parent object looks like. Maybe it's a shared_ptr. Maybe it's a unique_ptr. Maybe it's a reference (?). In such cases showing a raw pointer might be confusing?

@dfaure-kdab dfaure-kdab changed the title Show classnames next to objectNames, when difference Show classnames next to objectNames, when different Nov 13, 2023
@Waqar144
Copy link
Contributor

... Maybe it's a reference (?). In such cases showing a raw pointer might be confusing?

Right, I thought you were asking about whether to show an asterisk for the raw pointer case. Otherwise yeah, then just showing the className is enough. It also consumes less space (which is a somewhat important thing in this context)

Now that I saw the code and tried it out, I think I understand question a bit better. In the properties tab, just showing the objectName is more confusing imo. So I think className[objectName, this=value] and className[this=ADDRESS] is a good choice and consistent. The only downside I can see is the former taking more horizontal space, perhaps this=value can be skipped when we have object name.

@ferdnyc
Copy link
Contributor

ferdnyc commented Nov 18, 2023

The className is in parenthesis in one, outside everything in the other, and the pointer value is only shown in the case without an object name. So I was wondering if we should unify this somehow....
Maybe it could be className[objectName, this=value] ? I'm not 100% sure, because the object name might be the main thing we want to see.

I actually don't think standardizing around {objectName_or_value}(ClassName) would look terrible. e.g.

  • main(QMainWindow)
  • toolDock(QDockWidget)
  • 0xdcd22e0(QFrame)

(...Might encourage people to name their objects, too.)

@dfaure-kdab
Copy link
Member Author

I actually don't think standardizing around {objectName_or_value}(ClassName) would look terrible. e.g.

Thanks for the suggestion. I like it, it's much more consistent than what I have until now. I'll change it accordingly.

  Property     | Value                        | Type     | Class
Before:
  parent       | m_loadingWidget              | QObject* | QObject
After:
  parent       | m_loadingWidget (QSvgWidget) | QObject* | QObject

For consistency, change the case without object name from
"QFrame[this=0xdcd22e0]" to "0xdcd22e0 (QFrame)", as suggested
by ferdnyc.

The change propagated to other classes to fix const [in]correctness
(the const_cast is only because of QHash API, it shouldn't be necessary
for the caller of those methods).
@dfaure-kdab dfaure-kdab force-pushed the wip/dfaure/show_classnames branch from 79951c3 to eb5eab2 Compare November 20, 2023 13:04
@Waqar144
Copy link
Contributor

I actually don't think standardizing around {objectName_or_value}(ClassName) would look terrible. e.g.

+1 from me too

@dfaure-kdab dfaure-kdab merged commit b40e554 into master Nov 29, 2023
12 checks passed
@dfaure-kdab dfaure-kdab deleted the wip/dfaure/show_classnames branch November 29, 2023 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants