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

QCombobox and winId

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 2.2k 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.
  • R Offline
    R Offline
    Ruslan S.
    wrote on last edited by
    #1

    Hi. I have the question. My program creates a list of QComboBoxes in a cycle and user interacts with some of them. When i had a few comboboxes - no problems, each combobox I created one by one manually, but now I dont know, how many comboboxes user will need - 3 or 150. I read about WinId, that every Qwidget have and its unique, so after creating new QCombobox, program read his winId and write to list, but now I have a problem - I can`t read current value, that user select in it, including trying to use find() command. Can you help me with the example of using find() with QComboBox or I did all wrong and there is much easier way? Thanks.

    P.S. Sorry for my English.

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      Hi, and welcome to qt-project forum!!
      First of all, what do you want to achieve? Why so many combo boxes?
      What might be a more object orientated thought is to let every combo box handle it's own events (subclass combobox and reimplement) and send a signal if needed by the program. The program itself only needs to hold a QList of QCombo boxes and connect slots to them.
      Then again, this might not be what you want, so a bit of insight to what you want to create would be helpful.

      Greetz, Jeroen

      1 Reply Last reply
      0
      • raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #3

        yes there is an easier way ;) WinId is the wrong approach in this case.

        Whats exactly your usecase?
        How do you expect to receive the value changes?

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        0
        • R Offline
          R Offline
          Ruslan S.
          wrote on last edited by
          #4

          Thanks for your answers.
          My program is part of the company software for working with our databases. My question is about situation, when users choose some options for inserting needed data to database. In the previous version of program, there were a few QTable widgets, that user fill with their data, but now one of the column must be replace with choise, like combobox have. The main issue, that user had a button "Add new row" for the tables, so program doesn`t know, how many rows will be in the end (in some cases, more, than 20).
          Thanks.

          1 Reply Last reply
          0
          • raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by
            #5

            ok i think i understood you right.
            so you could create a QWidget subclass which represents your row.
            Each of those widgets creates it's set of QComboBoxes (for each column).
            I assume you know how to get the values from QComboBoxes and/or react on value selected signals, so i wont go in detail here.
            Create and place these row widgets how you like. You may also create methods for accessing a complete set of it's values at once.

            What i'm talking about is capsuling your QComboBoxes and break up your whole problem down to smaller pieces.

            Hope you understand what i mean.

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0
            • JeroentjehomeJ Offline
              JeroentjehomeJ Offline
              Jeroentjehome
              wrote on last edited by
              #6

              Hi,
              Isn't this more like implementing a proper Model/View situation with some extra buttons to add/remove rows and delegates to be filled with the comboBox for the row desired?
              With the "add to database" you write the data from the model to the database. Or even maybe use the database model implementation??
              Maybe a picture will tell more then words. How should it look? What raven-worx says is great if the widgets are not placed in a table, but since you first used a QtableWidget I guess you want a table??
              Also a column in a QTableWidget may be filled with a QComboBox, there are multiple examples of that.

              Greetz, Jeroen

              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