Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved how to set the item in Combo Box that will appear when the dialog is executed

    General and Desktop
    4
    5
    212
    Loading More Posts
    • 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.
    • F
      frnklu20 last edited by

      In my program i have 2 classes named CargaDialog and MainWindow.

      The CargaDialog, as its own name say, is a dialog. Inside this Dialog i have a Combo Box, and the items of this combo box are added from outside of de CargaDialog class and inside the MainWindow class.

      My problem is that i can add the items in the combo box, but i don't know how to set which item will appear in the "preview" when the Dialog is executed.

      How can i do it?

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        Add a method to your dialog to set which item the combobox should show.

        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 Reply Quote 0
        • F
          frnklu20 last edited by

          Hi,

          But how can i set this?how can i construct this method?

          K jsulm 2 Replies Last reply Reply Quote 0
          • K
            kenchan @frnklu20 last edited by

            @frnklu20
            you would usually call the setCurrentIndex(int index) or setCurrentText(const QString &text) function of the combobox.
            This will show the item with the index or the item with the text in the box at the top of the combobox.

            1 Reply Last reply Reply Quote 0
            • jsulm
              jsulm Lifetime Qt Champion @frnklu20 last edited by

              @frnklu20 said in how to set the item in Combo Box that will appear when the dialog is executed:

              how can i construct this method?

              Like any other method in C++.
              What exactly is the problem?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply Reply Quote 0
              • First post
                Last post