Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Need help implementing C++ code into a working GUI program (BIOINFORMATICS PROJECT)
Forum Updated to NodeBB v4.3 + New Features

Need help implementing C++ code into a working GUI program (BIOINFORMATICS PROJECT)

Scheduled Pinned Locked Moved C++ Gurus
7 Posts 3 Posters 6.8k 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
    ApacheOmega
    wrote on last edited by
    #1

    Hello I'm new to QT and C++, my primary language is JAVA (and I'm still a novice at that)
    But I want to learn how to use QT and C++ combined and create some awesome GUI programs
    I have a Bioinformatics program that reads a DNA sequence from a text file by imputing the file name then the DNA data appears
    after the DNA data appears each individual character of the DNA sequence is converted into an RNA sequence.
    what i want to happen is
    A)the file name to be entered in the first text field
    press a button
    B)the DNA data appears in the second text field
    press the second button
    C) the RNA sequence appears in the third text field

    I have the code written in C++ already i just want to learn how to implement it in a GUI program like QT

    here's my code
    Please help!!
    also are there any recommended tutorials out there to help achieve my goal?
    and can I design stuff in Photoshop or illustrator and use it in QT?
    @
    #include<iostream>
    #include<fstream>
    #include<cstdlib>
    #include <string>
    using namespace std;
    int input;
    int main()
    {

    char filename[50];
    ifstream seq;
    cin.getline(filename, 50);
    seq.open(filename);

    if(!seq.is_open()){
    exit(EXIT_FAILURE);
    }

    char DNA[50];
    char RNA[50];
    seq>>DNA;

    cout<< DNA <<" "<<endl;

    int len=0;
    for(int i=0; i<=sizeof(DNA); i++){

    if (DNA[i] == 'A')
    {cout<<"U";
    RNA[i]='U';
    len++;
    }
    if (DNA[i] == 'G')
    {cout<<"C";
    RNA[i]='C';
    len++;
    }
    if (DNA[i] == 'C')
    {cout<<"G";
    RNA[i]='G';
    len++;
    }

    if (DNA[i] == 'T')
    {cout<<"A";
    RNA[i]='A';
    len++;
    }
    }
    cout<<endl;
    for(int i=0; i<len; i++){
    cout<<RNA[i];
    }
    cout<<endl<<sizeof(DNA)<<endl;
    cout<<len<<endl;
    fstream file;
    file.open("RNA_DNASeq.txt",ios::out);
    file<<DNA<<endl<<RNA<<endl;
    file.close();

    system("PAUSE");
    return 0;
    }

    @

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Rahul Das
      wrote on last edited by
      #2

      Have you tried anything so far in Qt (Not QT)??

      If so, where are you finding difficulty ?

      There are just too many Video tutorials ,"How to":http://qt-project.org/doc/qt-4.8/how-to-learn-qt.html, "docs":http://qt-project.org/doc/qt-4.8/ and examples listed in this site. And an elaborated "wiki":http://qt-project.org/wiki/ too.


      Declaration of (Platform) independence.

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

        I've been looking at the tutorials and I find QT is way different then what I expected. where I find difficulty is understanding where I can write the code in the main.cpp folder and have the results of my logic appear and function between different components inside the mainwindow.cpp folder. I guess what I'm searching for is how to connect between code and design. I'm also having a little trouble following the syntax because it is fairly different that just regular C++ code (that's what I thought the concept of QT would be) I'm just so used to JAVA GUI capabilities its a little difficult getting used to. The one tutorial I'm looking at on youtube just shows you how to use the UI then it just shows you a bunch of coding examples and not how to connect that code to the GUI you created. Thats strictly what I'm looking for.

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

          oh yeah that link doesn't work.
          But thanks though.
          I hope i explained my issue correctly, I tend to ramble on.
          but one more example of what I'm talking about is this.

          say I calculate then cout these results

          @
          for(int i=0; i<=sizeof(DNA); i++){

          if (DNA[i] == 'A')
          {cout<<"U";
          RNA[i]='U';
          len++;
          }
          if (DNA[i] == 'G')
          {cout<<"C";
          RNA[i]='C';
          len++;
          }
          if (DNA[i] == 'C')
          {cout<<"G";
          RNA[i]='G';
          len++;
          }

          if (DNA[i] == 'T')
          {cout<<"A";
          RNA[i]='A';
          len++;
          }
          }
          cout<<endl;
          for(int i=0; i<len; i++){
          //I want to cout these results In a text field after the logic is through running
          //I want to learn how to use the on click feature in QT

          cout<<RNA[i];
          @

          1 Reply Last reply
          0
          • R Offline
            R Offline
            Rahul Das
            wrote on last edited by
            #5

            Qt is no different from regular c++ codes, except some macros, in a broad way if you see. :)

            Links are not working ??

            And the simplest way to start with is, creating a ui file using the designer , with a [[doc:QLabel]] on it. SetText on it. Thats is your out put :)

            bq. I design stuff in Photoshop or illustrator and use it in QT?

            I dont know what stuff are you talking about.. But yes, with images, icons etc.

            Edit:
            bq. A)the file name to be entered in the first text field
            press a button
            B)the DNA data appears in the second text field
            press the second button
            C) the RNA sequence appears in the third text field

            A) [[doc:QLineEdit]] and [[doc:QPushButton]]
            Or [[doc:QFileDialog]] as well.
            B) & C) see [[doc:QLabel]] Or [[doc:QTextEdit]]


            Declaration of (Platform) independence.

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goblincoding
              wrote on last edited by
              #6

              Sent you a message.

              http://www.goblincoding.com

              1 Reply Last reply
              0
              • R Offline
                R Offline
                Rahul Das
                wrote on last edited by
                #7

                DNA to RNA is interesting.. plus, for a kick start, here are some more tips.

                Use designer to make a form , with a button, and two labels.
                Connect button to a slot where you read the file, display DNA on one label, and RNA on another.

                say, the slot be ..
                @ QString DNA,RNA;
                QString file = QFileDialog::getOpenFileName(this,
                tr("Open DNA sequence file"), "", tr("DNA Files (*.txt)"));
                QFile f(file);
                if(f.open(QIODevice::ReadOnly | QIODevice::Text))
                {
                DNA = f.readAll();
                ui->your_first_label->setText(DNA);
                foreach(QChar c, DNA)
                {
                if(c=='G') RNA.append("C");
                else if(c=='A') RNA.append("U");
                else if(c=='C') RNA.append("G");
                else if(c=='T') RNA.append("A");
                }
                ui->your_second_label->setText(RNA);
                }@


                Declaration of (Platform) independence.

                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