Unable to copy values of QLabel
-
I am not able to copy the value of all the value of QLineEdit in following code
QGridLayout gridLayout = new QGridLayout;
QGroupBox gropuBox = new QGroupBox("name");
groupBox->setEnabled(false); /* read only /
QLabel ALabel = new QLabel(("attrName");
QLineEdit* ValueLabel = new QLineEdit(("attrValue");
ALabel->setBuddy(ValueLabel);
gridLayout->addWidget(attrLabel, lrow, lcol);
gridLayout->addWidget(attrValueLabel, lrow, ++lcol);I have make groupBox->setEnabled(true;) . then only I can copy the value of QlineEdit
-
Hi
What do you mean by values of QLabel ?How do u try to take those "values" ?
-
Ah, yes
If you disable the parent, then the childs are disabled too.
Its how it works. -
No I want to copy the values of QLineEdit
-
@Qt-Enthusiast
Yes but if you call disable on the QGroupBox and QLineEdit is inside that, the edit ALSO becomes
read only. -
so canwe copy read only varrables
-
@Qt-Enthusiast
Well, when not enabled, you can not interact with it.
But you can still read the text from code.But its not clear what you are trying :)
-
These attributes have to be read only as it should be changed at the same time we should be able to copy the values of these QLineEdit and paste on shell window
-
@Qt-Enthusiast
Ok, so what is the issue then?
Just tested.
Even when disabled then
qDebug() << ui->textEdit->toPlainText();
still get the text.So What are you trying ? and what is not working ?
-
When its its enabled then I can get a POP up on right click and can copy as well I can copy ctrl-c and ctrv ,when it disabled then it does not come
So the requirement , we should not able to change the value of QLineEdit but at the same time we should be able to copy the value of the POp up menu
-
@Qt-Enthusiast
oK, you can NOT interact with it when disabled. so there can be no popups from clicking it.
Use myTextEdit->setReadOnly(true) instead. -
thanks that worked
-
@Qt-Enthusiast
Super. Remember to mark as Solved :) -
One more question , I want to copy text next to checkbox in following code
QGroupBox* checkGroupBox = NULL;
QGroupBox* LabelGroupBox = NULL;
QGridLayout *checkGroupBoxLayout = NULL;
QGridLayout *labelGroupBoxLayout = NULL;int crow = 0, ccol = 0, lrow = 0, lcol = 0;
for (mymap<string,string>::iterator ni =tab.begin(); ni; ni++) {
string attrName = ni.object();
string attrValue = ni.value();if (attrValue == "true" || attrValue == "false") { if (!attrCheckGroupBox) { checkGroupBox = new QGroupBox(name); checkGroupBoxLayout = new QGridLayout; checkGroupBox->setLayout(attrCheckGroupBoxLayout); checkGroupBox->setEnabled(true); /* read only */ } QCheckBox* attrCheckBox = new QCheckBox((str_t)"attName"); attrCheckGroupBoxLayout->addWidget(attrCheckBox, crow, ccol); attrCheckBox->setChecked(attrValue == "true");
-
@Qt-Enthusiast said in Unable to copy values of QLabel:
Hi
"cop text next to checkbox "'
Sounds strange to me ?Do you mean , you want to create a new Label and sets it text and insert into the layout, next to the checkbox?
-
https://s30.postimg.org/m9i70o3dt/checkbox.png and I want to copy the value of text dont_use
-
@Qt-Enthusiast
Are you asking How to get text ?
checkbox->text() gives it -
No I should have pop up with Copy QAction and also should be able to select and copy and paste with Ctrl-C and Ctrl-V
-
@Qt-Enthusiast
So you want to add a context menu to it ?
Like edit has ?
I think you must create it yourself. -
Can u help
for coding and how to impliment CTRL +C and CTRL V