Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9018867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:38:23+00:00 2026-06-16T04:38:23+00:00

I am in the process of developing a html editor in Qt for one

  • 0

I am in the process of developing a html editor in Qt for one of my university assignments, and i am having a problem regarding naming of some variables.

the problem is this:

when the user decides to load their “project” the program iterates through the folder and finds how many .html files are in there, it then creates tabs for them to be displayed in.

I have a custom QTextEdit which has a customer completer and syntax highlighting etc. the problem i am having at the moment is how to create them depending on the number needed.

i create a QStringList of file names:

QStringList m_files;
            m_files = aDialog.m_loadDirectory->entryList(QStringList("*.html"),QDir::Files|QDir::NoSymLinks);

then i iterate through each one of the list:

for(int i=0; i<m_files.count();i++)
{

}

and for each one i need to create a new custom QtextEdit

TextEdit *name = new TextEdit;

then add to the tab

tabs->addTab(name,"someTitle");

but as each TextEdit needs to be different for each tab (i think this is correct) i need a different Variable name for each one.

i thought about creating a list/array of TextEdit objects but as i dont know how many i need to use, i could end up easily with too many (wasted memory) or not enough..

any ideas on how i can get around this?

one thought..

would it be possible to create a TextEdit object before the loop

then make a copy of that object in the loop and add the copied object to the tab? (still variable naming problem…)

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:38:24+00:00Added an answer on June 16, 2026 at 4:38 am

    but as each TextEdit needs to be different for each tab (I think this is correct)

    Yes, you need a different TextEdit in each tab.

    I need a different Variable name for each one.

    No, you don’t need a different variable name for each one. You need different objects, but variable names don’t have much to do with that.

    A simple:

    for (...) {
       TextEdit *te = new TextEdit(...);
       // set up that text edit in whatever way you need
       tabs->addWidget(te, "foo");
    }
    

    does exactly what you want. The variable name te is completely irrelevant (it won’t even appear in the executable outside of debugging symbols). Each time through the loop, you’ll be working on a separate TextEdit instance.

    If you need to refer to that TextEdit by name at runtime, you can keep all your widgets in a collection, a QMap for instance.

     QMap<QString, QWidget*> all_editors;
     ...
    
     for (...) {
        TextEdit *te = ...;
        all_editors[filename] = te;
        ...
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In process of developing I often face with the next problem: if some method
We're in process of developing a desktop application which needs to record user's screen
I‘m developing chrome extension. user log in in options.html,and then application will load much
we are in process of developing google chrome extension, in which we need to
We are in process of developing an Java based CMS related to travelling domain
I'm in the process of developing a Silverlight custom control that hosts a Flash
I'm in the process of developing several custom build scripts for TFS and I'd
I'm in the process of developing a visualization engine for the company I work
I'm in the process of developing a custom MMC 3.0 snap-in and was wondering
I'm in the process of developing a website that makes use of JQuery's superfish.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.