Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Unable to copy values of QLabel
Qt 6.12 LTS is out! See what's new in the release blog

Unable to copy values of QLabel

Scheduled Pinned Locked Moved Unsolved General and Desktop
24 Posts 2 Posters 13.9k Views 2 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by
    #8

    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

    mrjjM 1 Reply Last reply
    0
    • Q Qt Enthusiast

      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

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #9

      @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 ?

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        Qt Enthusiast
        wrote on last edited by Qt Enthusiast
        #10

        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

        mrjjM 1 Reply Last reply
        0
        • Q Qt Enthusiast

          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

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #11

          @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.

          1 Reply Last reply
          2
          • Q Offline
            Q Offline
            Qt Enthusiast
            wrote on last edited by
            #12

            thanks that worked

            mrjjM 1 Reply Last reply
            1
            • Q Qt Enthusiast

              thanks that worked

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #13

              @Qt-Enthusiast
              Super. Remember to mark as Solved :)

              1 Reply Last reply
              0
              • Q Offline
                Q Offline
                Qt Enthusiast
                wrote on last edited by
                #14

                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");
                
                mrjjM 1 Reply Last reply
                0
                • Q Qt Enthusiast

                  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");
                  
                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #15

                  @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?

                  1 Reply Last reply
                  0
                  • Q Offline
                    Q Offline
                    Qt Enthusiast
                    wrote on last edited by
                    #16

                    https://s30.postimg.org/m9i70o3dt/checkbox.png and I want to copy the value of text dont_use

                    mrjjM 1 Reply Last reply
                    0
                    • Q Qt Enthusiast

                      https://s30.postimg.org/m9i70o3dt/checkbox.png and I want to copy the value of text dont_use

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #17

                      @Qt-Enthusiast
                      Are you asking How to get text ?
                      checkbox->text() gives it

                      1 Reply Last reply
                      0
                      • Q Offline
                        Q Offline
                        Qt Enthusiast
                        wrote on last edited by
                        #18

                        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

                        mrjjM 1 Reply Last reply
                        0
                        • Q Qt Enthusiast

                          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

                          mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by
                          #19

                          @Qt-Enthusiast
                          So you want to add a context menu to it ?
                          Like edit has ?
                          I think you must create it yourself.

                          1 Reply Last reply
                          0
                          • Q Offline
                            Q Offline
                            Qt Enthusiast
                            wrote on last edited by
                            #20

                            Can u help
                            for coding and how to impliment CTRL +C and CTRL V

                            mrjjM 1 Reply Last reply
                            0
                            • Q Qt Enthusiast

                              Can u help
                              for coding and how to impliment CTRL +C and CTRL V

                              mrjjM Offline
                              mrjjM Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on last edited by mrjj
                              #21

                              @Qt-Enthusiast
                              It will be the same as any other menu using shortcuts etc.

                              Maybe go look for some sample. I dont have any.
                              its not trivial to replicate the default context menu.
                              It will take some code.

                              Maybe other have a better idea. I guess this has been asked before. so give it some time and see :)

                              I would look into
                              QLineEdit::createStandardContextMenu().

                              maybe you can just hook it to the checkbox

                              1 Reply Last reply
                              0
                              • Q Offline
                                Q Offline
                                Qt Enthusiast
                                wrote on last edited by
                                #22

                                Anu reference code for the same

                                mrjjM 2 Replies Last reply
                                0
                                • Q Qt Enthusiast

                                  Anu reference code for the same

                                  mrjjM Offline
                                  mrjjM Offline
                                  mrjj
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #23

                                  @Qt-Enthusiast
                                  https://forum.qt.io/topic/31233/how-to-create-a-custom-context-menu-for-qtableview

                                  key points being
                                  setContextMenuPolicy(Qt::CustomContextMenu);
                                  connect(table, SIGNAL(customContextMenuRequested(QPoint)),SLOT(customMenuRequested(QPoint)));

                                  1 Reply Last reply
                                  0
                                  • Q Qt Enthusiast

                                    Anu reference code for the same

                                    mrjjM Offline
                                    mrjjM Offline
                                    mrjj
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #24

                                    @Qt-Enthusiast

                                    Also, please dont RUSH over
                                    QLineEdit::createStandardContextMenu().

                                    You be able to create it this way and then just connect the signals to your slots to copy
                                    the text.

                                    I did not try this but it might save you time.

                                    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
                                    • Unsolved