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 7029441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:32:23+00:00 2026-05-28T00:32:23+00:00

I was creating a very simple class as part of a much larger project.

  • 0

I was creating a very simple class as part of a much larger project. The class was as simple as:

class Login : public QDialog
{
    Q_OBJECT
    private:
        QLineEdit* txtUser;
        QLineEdit* txtPass;
        void setupUI();
    public:
        Login(QWidget* parent = 0);
};

When attempting to create the setupUI() function the line txtUser = new QLineEdit; would crash. I tried changing a lot of things and nothing would help. I took the project, copied it, and removed everything except this class and a main.cpp and there was no error. I returned to my original project (reloading Qt Creator) and it continued to fail. I began commenting out random self-written header files from the main in case of some sort of conflict. After commenting out each one, I would re-compile and run. Each time it would continue to fail. After the last one, it worked. Then, I re-enabled everything and it ran great once again.

So, my question is, what could cause a segfault of this type with such simple code? In addition what might my changes have done to fix it if no code was changed? Basically, if I get this problem to ever occur again and I’m sure there are no errors, what steps should I take?

Please keep in mind I am using Qt and Qt Creator within Windows.

Finally, for the sake of completion, here is the code within setupUI():

void Login::setupUI()
{
    QVBoxLayout* main = new QVBoxLayout;
    QHBoxLayout* userBox = new QHBoxLayout;
    QHBoxLayout* passBox = new QHBoxLayout;
    txtUser = new QLineEdit;
    txtPass = new QLineEdit;
    userBox->addWidget(new QLabel("User Name:"));
    userBox->addWidget(txtUser);
    passBox->addWidget(new QLabel("Password:"));
    txtPass->setEchoMode(QLineEdit::Password);
    passBox->addWidget(txtPass);
    main->addLayout(userBox);
    main->addLayout(passBox);
    setLayout(main);
}
  • 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-05-28T00:32:24+00:00Added an answer on May 28, 2026 at 12:32 am

    Sometimes you need to run qmake to make it work. You can do that right from QtCreator.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a very simple EF4 code first project with one entity. public
I am creating a very simple forum as my first MVC project. My database
I am creating a very simple project on OpenGL and I'm stuck with rotations.
Original Question: Hello, I am creating very simple hobby project - browser based multiplayer
I have a very simple Java JTable question. I am creating this class to
I'm creating a very simple django upload application but I want to make it
I am creating a very simple web service and I don't want to bother
I am experiencing some performance problems when creating a very simple Python HTTP server.
Good morning, A bit of background might help. I'm creating a very simple app
I am creating a formal spec for a very simple rule language, very simple.

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.