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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:51:01+00:00 2026-05-20T08:51:01+00:00

When I run it it will just finish right away and not show anything.

  • 0

When I run it it will just finish right away and not show anything. I can’t find anything wrong w/it and no one on #qt could either. I’ve got other apps working fine so I’m not sure. It’s got something to do with the createForm call, if I omit that call in the constructor I do get a default QWidget displayed.

captchit.pro

    #-------------------------------------------------
    #
    # Project created by QtCreator 2011-02-26T20:58:23
    #
    #-------------------------------------------------

QT += core gui network

TARGET = captchit TEMPLATE = app

SOURCES += main.cpp\ widget.cpp

HEADERS += widget.h

main.cpp

    #include "QtGui/QApplication"
    #include "widget.h"

int main(int argc, char *argv[]) { QApplication a(argc, argv); Widget mainWidget; mainWidget.show();

return a.exec();

}

widget.h

    #ifndef WIDGET_H
    #define WIDGET_H

#include <QWidget>

class QPixmap;
class QLabel;
class QLineEdit;
class QPushButton;

class Widget : public QWidget
{
Q_OBJECT

public:
Widget(QWidget *parent = 0);

private slots:
void on_refreshButton_pressed();
void on_submitButton_pressed();
void on_closeButton_pressed();

private:
QPixmap captchaImage;
QLabel *imageLabel;
QLabel *statusLabel;
QLineEdit *captchaLineEdit;
QPushButton *submitButton;
QPushButton *refreshButton;
QPushButton *closeButton;

void createForm();
void createActions();
void getCaptcha();
void submitCaptcha();

};

endif // WIDGET_H

widget.cpp

    #include "widget.h"
    #include "QtNetwork/QtNetwork"
    #include "QtGui"

void Widget::on_refreshButton_pressed() { ; }

void Widget::on_submitButton_pressed() { ; }

void Widget::on_closeButton_pressed() { ; }

// Create UI Components void Widget::createForm() { // Create Main Layout QVBoxLayout *mainLayout = new QVBoxLayout(this);

// // set captcha pixmap to imageLabel for displaying // imageLabel->setPixmap(captchaImage);

// Create Buttons
QVBoxLayout *buttonLayout = new QVBoxLayout();
submitButton->setText("Submit");
refreshButton->setText("Refresh");
closeButton->setText("Close");
buttonLayout->addWidget(submitButton);
buttonLayout->addWidget(refreshButton);
buttonLayout->addWidget(closeButton);

// Complete Layouts
// lineEdit & submitStatus
QVBoxLayout *lineEditLayout = new QVBoxLayout();
lineEditLayout->addStretch();
lineEditLayout->addWidget(statusLabel);
lineEditLayout->addWidget(captchaLineEdit);
lineEditLayout->addStretch();

// Create Bottom Layout
QHBoxLayout *bottomLayout = new QHBoxLayout();
bottomLayout->addLayout(lineEditLayout);
bottomLayout->addLayout(buttonLayout);

// Add to mainLayout

// mainLayout->addWidget(imageLabel);
mainLayout->addLayout(bottomLayout);
setLayout(mainLayout);
}

// Bind Slots and Signals
void Widget::createActions()
{
;
}

void Widget::getCaptcha()
{
;
}

void Widget::submitCaptcha()
{
;
}

Widget::Widget(QWidget *parent) :
QWidget(parent)
{
createForm();
// createActions();
}

  • 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-20T08:51:02+00:00Added an answer on May 20, 2026 at 8:51 am

    You need to initialize your private class members, probably in your constructor, before you use them.

    Widget::Widget(QWidget* parent) :
        QWidget(parent)
    {
        captchaImage = new QPixmap;
        imageLabel = new QLabel(this);
        statusLabel = new QLabel(this);
        captchaLineEdit = new QLineEdit(this);
        submitButton = new QPushButton(this);
        refreshButton = new QPushButton(this);
        closeButton = new QPushButton(this);
    
        createForm();
    //    createActions();
    }
    

    Also note that QPixmap does not derive from QObject, so you’ll have to delete it manually. It may be better to remove the QPixmap *captchaImage member from your class and use temporary QPixmap objects in your code.

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

Sidebar

Related Questions

The app will run fine, then crash - literally every other time. It seems
I am developing an application that will run on 64 bit computers. However, we
I am compiling my program that will run on linux gcc 4.4.1 C99. I
I am making an application which will run automatically on phone start up. Now
I am writing a process that will run continuously, getting messages on a queue
I have a button that when clicked will run a stored procedure on a
When I develop a C# console application (which will run on a server) and
I'm writing a PHP process that will run on a Unix machine that will
I'm writing a simple program that will run entirely client-side. (Desktop programming? do people
I need to create a desktop application that will run third party code, and

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.