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
Forum Updated to NodeBB v4.3 + New Features

Selected item from QListWidget

Scheduled Pinned Locked Moved General and Desktop
19 Posts 3 Posters 9.1k Views 1 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.
  • S Offline
    S Offline
    SGaist
    Lifetime Qt Champion
    wrote on 21 Jul 2014, 11:31 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 21 Jul 2014, 12:14 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
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 21 Jul 2014, 21:54 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 22 Jul 2014, 13:11 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
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 22 Jul 2014, 20:45 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 24 Jul 2014, 11:28 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
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 24 Jul 2014, 22:18 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 25 Jul 2014, 14:51 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
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 25 Jul 2014, 18:54 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 28 Jul 2014, 12:37 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
                      • S Offline
                        S Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 28 Jul 2014, 12:54 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

                        18/19

                        28 Jul 2014, 12:37

                        • Login

                        • Login or register to search.
                        18 out of 19
                        • First post
                          18/19
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved