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(); }