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. Selected item from QListWidget

Selected item from QListWidget

Scheduled Pinned Locked Moved General and Desktop
19 Posts 3 Posters 8.9k 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.
  • D Offline
    D Offline
    david_aa
    wrote on last edited by
    #6

    Hi ambershark,

    I did what you said, but the error continues. Please see

    @QList<QListWidgetItem *> itemList = ui.m_listPacote->selectedItems();

    // if so, m_LineCommand.clear();
    m_LineCommand += ";";
     
    for (int i=0;i<itemList.size();i++)
    {
       m_LineCommad += itemList.at(i)->text();
       if (i < itemList.size())
          m_LineCommand += ";";
    }@
    

    Errors:

    1- In this line: connect(ui.m_buttonOk(), SIGNAL(clicked(bool)), this, SLOT(OnBnClickedOk())); * (Error: error C2064: term does not evaluate to a function taking 0 arguments* )

    2- In this line: m_LineCommad += itemList.at(i)->text(); (Error: error C2679: binary '+=' : no operator found which takes a right-hand operand of type 'QString' (or there is no acceptable conversion))

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #7

      What is the type of m_LineCommand ? I guess not a QString

      ui.m_buttonOk() is wrong, it's ui.m_buttonOk, m_buttonOk is not a function.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • D Offline
        D Offline
        david_aa
        wrote on last edited by
        #8

        Hi SGaist

        So what to do is the following.
        I have a form with fields: DateInitial and DateEnd; TimeInitial and TimeEnd; listPackt; ListID; listStation; listComm

        And I need to get these values ​​in a command line that I will use later. So I created the variable "string m_LineCommand" which will store these values ​​as follows:

        Example: "04/09/2002 08:00:00.000; 05/09/2002 12:33:33.000; <list pckType>; <list pckID>; <list ET>; <list ComTYpe>;"

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #9

          Since you are using Qt, why don't you use QString for m_LineCommand ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • D Offline
            D Offline
            david_aa
            wrote on last edited by
            #10

            Hi SGaist,

            I'm rewriting a project developed in C + + using MFC. I'm also new to Qt, but now reading I saw what was going wrong. The correct is QString

            Another question please.

            When I comment the lines:

            @
            connect (ui.m_buttonOk, SIGNAL (clicked (bool)), this, SLOT (OnBnClickedOk ()));

             QList <QListWidgetItem *> ITEMLIST = ui.m_listPacote-> selectedItems ();
                 
             
                 / / If so, m_LineCommand.clear ();
                 m_LineCommand + = ";"
                 
                 for (int i = 0; i <itemList.size (); i + +)
                 {
                    m_LineCommad itemList.at = + (i) -> text ();
                    if (i <itemList.size ())
                       m_LineCommand + = ";"
                 }@
            

            The Qt does not lock and run my form, but keep the uncommented lines to load the form and try to select an option, the form Qt crashes. What can it be?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #11

              Your question is not clear at all, can you rephrase it please ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • D Offline
                D Offline
                david_aa
                wrote on last edited by
                #12

                Hi,

                I managed to solve, first I went "Clean Solution", then I went on "Rebuild Solution"

                But can you please help me with this part of the code.

                I need to get the Initial Date, End Date and concatenate them. I did this:

                @// Declaration of Variables
                string strDate, strInitialDate, strFinalDate;
                string a_pckIdList;

                QString csDate;
                CSPTDateTime DateTimeInitial;
                CSPTDateTime DateTimeFinal;

                // Recovering the Initial Date of the calendar

                DateTimeInitial = ui.m_initialDate->GetDateSelect();
                if (DateTimeInitial.GetYMD(strDate,2) == SPTERRO) return;
                strInitialDate = strDate.substr(0, 11);@

                But this errors occurs: "ERRORS": http://pastebin.com/AKtB8zdC

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #13

                  I can't since I don't know what's in CSPTDatePopup.h

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    david_aa
                    wrote on last edited by
                    #14

                    Hi,

                    This CSPTDatePopup.h is an internal class that I need to use. But my question is how should I do to get the Initial Date and End Date and concatenate.

                    Can you help me, please?

                    Thanks,

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #15

                      You might need to use it, but it seems that the error comes from it.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • D Offline
                        D Offline
                        david_aa
                        wrote on last edited by
                        #16

                        Hi,

                        But In this Line: DateTimeInitial = ui.m_initialDate->GetDateSelect();
                        error C2039: 'GetDateSelect' : is not a member of 'QCalendarWidget'

                        Can you hep me?

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #17

                          Beside telling you that you are calling a function that doesn't exist in QCalendarWidget… You might be rather looking for selectedDate

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0
                          • D Offline
                            D Offline
                            david_aa
                            wrote on last edited by
                            #18

                            Hi,

                            Can you help me?

                            In this line is occurs this error: (Line) DateTimeInitial = ui.m_initialDate->selectedDate();

                            (Error)
                            error C2679: binary '=' : no operator found which takes a right-hand operand of type 'QDate' (or there is no acceptable conversion)

                            This line: if (DateTimeInitial.GetYMD(strDate,2) == SPTERRO) return;
                            This error: error C2664: 'CSPTDateTime::GetYMD' : cannot convert parameter 1 from 'QString' to 'std::string &'

                            This line: strInitialDate = strDate.substr(0, 11);
                            error C2039: 'substr' : is not a member of 'QString'

                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #19

                              Please, read the documentation of the classes you are using. You can't use = to automagically put a QDate in a QString. You can't auto convert QString in string.

                              First thing to do: cleanup your code. You are uselessly mixing Qt with some other library. If you need to return a string somewhere, fine, but do the conversion at the last time, there's no need to go back and forth between different library types like that.

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              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