Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. retrieve text inside QLineEdit inside QTableWidget
Forum Updated to NodeBB v4.3 + New Features

retrieve text inside QLineEdit inside QTableWidget

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 351 Views
  • 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.
  • L Offline
    L Offline
    Lightshadown
    wrote on last edited by
    #1

    Hi, im trying to get the data displayed in a QTableWidget, everything comes from a database and some calculations to the data itself, everytime i want to retrieve the data from a cell using the follow code, my program wont compile with the follow error error: use of deleted function 'QLineEdit::QLineEdit(const QLineEdit&) the table was made with Qt Designer

    QLineEdit a = widget_PP.Registros_General->cellWidget(1,1)->findChild<QLineEdit>();
    

    as far as i know the cellwidget retrieves the data inside the qwidget, i also used a qobject_cast but i got a similar error

    QLineEdit a = qobject_cast<QLineEdit>(widget_PP.Registros_General->cellWidget(0,0));
    

    i need the information display on the QTableWidget so i can send it to my printer, any idea where i might be wrong? i did try using item(), but that wont work because im using a QlineEdit

    JonBJ 1 Reply Last reply
    0
    • L Lightshadown

      Hi, im trying to get the data displayed in a QTableWidget, everything comes from a database and some calculations to the data itself, everytime i want to retrieve the data from a cell using the follow code, my program wont compile with the follow error error: use of deleted function 'QLineEdit::QLineEdit(const QLineEdit&) the table was made with Qt Designer

      QLineEdit a = widget_PP.Registros_General->cellWidget(1,1)->findChild<QLineEdit>();
      

      as far as i know the cellwidget retrieves the data inside the qwidget, i also used a qobject_cast but i got a similar error

      QLineEdit a = qobject_cast<QLineEdit>(widget_PP.Registros_General->cellWidget(0,0));
      

      i need the information display on the QTableWidget so i can send it to my printer, any idea where i might be wrong? i did try using item(), but that wont work because im using a QlineEdit

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Lightshadown
      Read the docs carefully! Both findChild<QLineEdit>(); and cellWidget(0,0) will return a pointer to the widget. Your code is written for returning the widget itself, which is the cause of the error messages:

      QLineEdit *a = widget_PP.Registros_General->cellWidget(1,1)->findChild<QLineEdit>();
      QLineEdit *a = qobject_cast<QLineEdit *>(widget_PP.Registros_General->cellWidget(0,0));
      

      Of course these will only find such a QLineEdit if you have previously gone setCellWidget().

      L 1 Reply Last reply
      2
      • JonBJ JonB

        @Lightshadown
        Read the docs carefully! Both findChild<QLineEdit>(); and cellWidget(0,0) will return a pointer to the widget. Your code is written for returning the widget itself, which is the cause of the error messages:

        QLineEdit *a = widget_PP.Registros_General->cellWidget(1,1)->findChild<QLineEdit>();
        QLineEdit *a = qobject_cast<QLineEdit *>(widget_PP.Registros_General->cellWidget(0,0));
        

        Of course these will only find such a QLineEdit if you have previously gone setCellWidget().

        L Offline
        L Offline
        Lightshadown
        wrote on last edited by
        #3

        @JonB i did follow your advice and used the pointer, my error was the lack of the pointer and now its working properly, thanks
        working code:

        QLineEdit *a = widget_PP.Registros_General->cellWidget(1,1)->findChild<QLineEdit*>(); // this works
        
        QLineEdit *a = qobject_cast<QLineEdit*>(widget_PP.Registros_General->cellWidget(1,1))  // doing object cast works as well
        
        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 Extensions
        • Unsolved