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. how to set the item in Combo Box that will appear when the dialog is executed
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 4 Posters 536 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.
  • F Offline
    F Offline
    frnklu20
    wrote on last edited by
    #1

    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
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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
      0
      • F Offline
        F Offline
        frnklu20
        wrote on last edited by
        #3

        Hi,

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

        K jsulmJ 2 Replies Last reply
        0
        • F frnklu20

          Hi,

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

          K Offline
          K Offline
          kenchan
          wrote on last edited by
          #4

          @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
          0
          • F frnklu20

            Hi,

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

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

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

            • Login

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