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 do you handle these cases?

How do you handle these cases?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 399 Views 3 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
    Stefanoxjx
    wrote on last edited by
    #1

    Hi, I've a couple of doubts:
    1 - When you works with databases, how do you transport secondary data or data not to be displayed (like records id and other) for each records?
    In my specific case, I work with QTableWidget and I do this inserting the secondary data in hided columns.
    What do you think about it?

    2 - I am going crazy with columns width in QTableWidget.
    I've 3 column and I would like the first to be wider than the other two.
    To do this, I've setColumnWith for 2nd and 3nd column at my discrection and for first column, I set width taking QTableWidget width and subtracting width of 2nd and 3nd columns.
    The result is that the 3nd column exits QTableWidget.
    If I set first columnd at my discrection, the risk is that 3nd column will be too large or too tight.
    How do you handle these cases?

    Grazie.

    JonBJ kshegunovK 2 Replies Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by Kent-Dorfman
      #2

      to point (1): I never move SQL rerieved data directly to a Qt widget. I always create a transaction model class to abstract the access to the database into well defined and discrete transactions, and create methods specifically to provide only the needed data. As for how to link the table data to a specific (nondisplayed) record number, you can probably subclass the table cell to contain display data and hidden metadata.

      Cannot speak to the other points because I don't generally use that widget.

      If you meet the AI on the road, kill it.

      1 Reply Last reply
      0
      • S Stefanoxjx

        Hi, I've a couple of doubts:
        1 - When you works with databases, how do you transport secondary data or data not to be displayed (like records id and other) for each records?
        In my specific case, I work with QTableWidget and I do this inserting the secondary data in hided columns.
        What do you think about it?

        2 - I am going crazy with columns width in QTableWidget.
        I've 3 column and I would like the first to be wider than the other two.
        To do this, I've setColumnWith for 2nd and 3nd column at my discrection and for first column, I set width taking QTableWidget width and subtracting width of 2nd and 3nd columns.
        The result is that the 3nd column exits QTableWidget.
        If I set first columnd at my discrection, the risk is that 3nd column will be too large or too tight.
        How do you handle these cases?

        Grazie.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @Stefanoxjx
        In addition to @Kent-Dorfman. If retrieving from a database I would not normally choose a QTableWidget. That is a wrapper around QTableView, and includes its own data model. You are going to have to copy your data out of, say, a QSqlTableModel and into the QTableView, and vice versa if you allow editing. I would use a QTableView against the data model fetched.

        1 Reply Last reply
        1
        • S Stefanoxjx

          Hi, I've a couple of doubts:
          1 - When you works with databases, how do you transport secondary data or data not to be displayed (like records id and other) for each records?
          In my specific case, I work with QTableWidget and I do this inserting the secondary data in hided columns.
          What do you think about it?

          2 - I am going crazy with columns width in QTableWidget.
          I've 3 column and I would like the first to be wider than the other two.
          To do this, I've setColumnWith for 2nd and 3nd column at my discrection and for first column, I set width taking QTableWidget width and subtracting width of 2nd and 3nd columns.
          The result is that the 3nd column exits QTableWidget.
          If I set first columnd at my discrection, the risk is that 3nd column will be too large or too tight.
          How do you handle these cases?

          Grazie.

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #4

          @Stefanoxjx said in How do you handle these cases?:

          1 - When you works with databases, how do you transport secondary data or data not to be displayed (like records id and other) for each records?
          In my specific case, I work with QTableWidget and I do this inserting the secondary data in hided columns.
          What do you think about it?

          I think (but take it with a grain of salt) that the widget item allows for "user data" to be stored. I personally never use the widgets built upon the views. I'd always opt for a model of my making and a regular Q*View.

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          2

          • Login

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