When changing the object name in qt designer, even the variable name is changed
-
wrote on 10 Mar 2022, 08:24 last edited by
- ui_widget
tableWidget = new usrTableWidget(frm_Table); tableWidget->setObjectName(QString::fromUtf8("tableWidget")); tableWidget->setStyleSheet(QString::fromUtf8("")); tableWidget->setShowGrid(true); horizontalLayout_6->addWidget(tableWidget);
Is there a way to change only setObjectName on the designer surface?
The object name on the screen is related to the variable name.
-
If it can be changed programmatically, I think there is no reason why it can't be changed in the designer.
wrote on 10 Mar 2022, 23:33 last edited by Pl45m4 3 Oct 2022, 23:54@IknowQT said in When changing the object name in qt designer, even the variable name is changed:
I think there is no reason why it can't be changed in the designer.
Because you access the gui elements from your
uic
compiled header by using the object name given in QtDesigner (your.ui
file).In addition you can set/change object name with your code. IIRC objects you create in your classes dont have a object name by default... So why should there only be one way?
setObjectname
has to stay in and without a object name set by QtDesigner in yourui
file, you would not be able to use these files and do some default connections (access elements from UI file directly using the UI pointer).uic
creates the designer object variables based on their object names and sets the object name in the resulting header file.Edit:
The explanation above is a bit clunky :)
The reason is, thatuic
takes the name from your UI file and creates your compiledui_xxx.h
header... In this header, your pre-designed objects have a object name and variable name which is equivalent to the object name in your design file... QtDesigner / UIC is not responsible for changes you make afterwards...Like @Christian-Ehrlicher said... What's the point of having/explicitly wanting different names?
-
- ui_widget
tableWidget = new usrTableWidget(frm_Table); tableWidget->setObjectName(QString::fromUtf8("tableWidget")); tableWidget->setStyleSheet(QString::fromUtf8("")); tableWidget->setShowGrid(true); horizontalLayout_6->addWidget(tableWidget);
Is there a way to change only setObjectName on the designer surface?
The object name on the screen is related to the variable name.
@IknowQT said in When changing the object name in qt designer, even the variable name is changed:
The object name on the screen is related to the variable name.
And what's wrong with it?
If you want another object name than the variable name (for unknown reason) then you have to set it programatically. -
@IknowQT said in When changing the object name in qt designer, even the variable name is changed:
The object name on the screen is related to the variable name.
And what's wrong with it?
If you want another object name than the variable name (for unknown reason) then you have to set it programatically.wrote on 10 Mar 2022, 23:06 last edited byIf it can be changed programmatically, I think there is no reason why it can't be changed in the designer.
-
If it can be changed programmatically, I think there is no reason why it can't be changed in the designer.
wrote on 10 Mar 2022, 23:33 last edited by Pl45m4 3 Oct 2022, 23:54@IknowQT said in When changing the object name in qt designer, even the variable name is changed:
I think there is no reason why it can't be changed in the designer.
Because you access the gui elements from your
uic
compiled header by using the object name given in QtDesigner (your.ui
file).In addition you can set/change object name with your code. IIRC objects you create in your classes dont have a object name by default... So why should there only be one way?
setObjectname
has to stay in and without a object name set by QtDesigner in yourui
file, you would not be able to use these files and do some default connections (access elements from UI file directly using the UI pointer).uic
creates the designer object variables based on their object names and sets the object name in the resulting header file.Edit:
The explanation above is a bit clunky :)
The reason is, thatuic
takes the name from your UI file and creates your compiledui_xxx.h
header... In this header, your pre-designed objects have a object name and variable name which is equivalent to the object name in your design file... QtDesigner / UIC is not responsible for changes you make afterwards...Like @Christian-Ehrlicher said... What's the point of having/explicitly wanting different names?
-
@IknowQT said in When changing the object name in qt designer, even the variable name is changed:
I think there is no reason why it can't be changed in the designer.
Because you access the gui elements from your
uic
compiled header by using the object name given in QtDesigner (your.ui
file).In addition you can set/change object name with your code. IIRC objects you create in your classes dont have a object name by default... So why should there only be one way?
setObjectname
has to stay in and without a object name set by QtDesigner in yourui
file, you would not be able to use these files and do some default connections (access elements from UI file directly using the UI pointer).uic
creates the designer object variables based on their object names and sets the object name in the resulting header file.Edit:
The explanation above is a bit clunky :)
The reason is, thatuic
takes the name from your UI file and creates your compiledui_xxx.h
header... In this header, your pre-designed objects have a object name and variable name which is equivalent to the object name in your design file... QtDesigner / UIC is not responsible for changes you make afterwards...Like @Christian-Ehrlicher said... What's the point of having/explicitly wanting different names?
wrote on 11 Mar 2022, 06:20 last edited byI was trying to apply a style sheet, but there was a way to apply a style by object name. While testing it, I asked a question because I thought it would be easier to change it in a design tool rather than changing it by programming.
1/5