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 get common element from a group of QStringList?

How to get common element from a group of QStringList?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 4.0k 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.
  • A Offline
    A Offline
    aurora
    wrote on last edited by
    #1

    Hi all,
    I have problem, in my program i'm using a hash variable
    QHash<QString,QStringList> HFileSignal;
    It is a hash of file name and signal name list inside the file.
    Now i want to find common signals from al those file.

    So kindly tell me

    1. Is there any buit in function in Qt to achieve this?
      2.How can i declare a variable name on fly(while running program, inside a loop i must able to declare the variable)?
    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      @1
      Easiest would be to convert each contained QStringList into a QSet<QString>, and then use QSet::intersect() to get the intersection (shared elements) of these sets.

      @2
      Get yourself a C++ book, and think logically about what a variable is, what role it plays, and what the role of the compiler is.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        aurora
        wrote on last edited by
        #3

        [quote author="Andre" date="1326093083"]
        @2
        Get yourself a C++ book, and think logically about what a variable is, what role it plays, and what the role of the compiler is. [/quote]

        Thank u Andre....
        About my 2nd question...
        I meant to say... in a loop i want to create variables like var1,var2, var3.......varN, depending on certain count, that count is again variable....How can i do that?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          You don't. You can not declare variables-with-variable-names at runtime. At least, not in a compiled language like C++. Think about it: when would the compiler get to see those variables exactly?

          I think you need a data structure like a QVector, but we can only guess because you don't tell us what you need. However, this is really where some basic C++ knowledge comes in. I am serious: get yourself a good C++ book and use that to learn about the structure of C++ applications, data structures, pointers, etc.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            aurora
            wrote on last edited by
            #5

            Ok thank u Andre..:)
            I'll consider your valuable suggestion...I'll go through that book....

            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