New form (ui) .problem :/
Hello :) I am developing a new project and and it is the first for me with qt. I made a second form (ui) .I added some buttons and a qwebview then i added to a button of the mainwindow form a call to show the second form(browser.h) ...
Code:
browser bowser1;
browser1.show();
Button works normal and call the new form (browser.h)...But and this is the problem that the form which is called is empty! just a blank page without the widgets i added on ! :/:(
Re: New form (ui) .problem :/
First: it makes little sense to post code that is not the actual code.
Second: is "browser" a class generated by QtCreator template (form class)? If not, did you correctly instantiate the UI class and call its setupUi() function?
Does the form have proper layouting?
Cheers,
_
Re: New form (ui) .problem :/
Quote:
Originally Posted by
anda_skoa
First: it makes little sense to post code that is not the actual code.
Second: is "browser" a class generated by QtCreator template (form class)? If not, did you correctly instantiate the UI class and call its setupUi() function?
Does the form have proper layouting?
Cheers,
_
Well i will give more info to sort it out
browser.h
Code:
#ifndef BROWSER_H
#define BROWSER_H
#include <QWidget>
namespace Ui {
class browser;
}
{
Q_OBJECT
public:
explicit browser
(QWidget *parent
= 0);
~browser();
private slots:
void on_pushButton_clicked();
void on_pushButton_2_clicked();
void on_pushButton_4_clicked();
void on_pushButton_3_clicked();
void on_lineEdit_textEdited
(const QString &arg1
);
void on_webView_destroyed();
void on_browser_accepted();
private:
Ui::browser *ui;
};
#endif // BROWSER_H
browser.cpp
Code:
#include "browser.h"
#include "ui_browser.h"
browser
::browser(QWidget *parent
) : ui(new Ui::browser)
{
// ui->setupUi(this);
}
browser::~browser()
{
delete ui;
}
void browser::on_pushButton_clicked()
{
}
void browser::on_pushButton_2_clicked()
{
}
void browser::on_pushButton_4_clicked()
{
}
void browser::on_pushButton_3_clicked()
{
}
void browser
::on_lineEdit_textEdited(const QString &arg1
) {
}
void browser::on_webView_destroyed()
{
}
void browser::on_browser_accepted()
{
}
In mainwindow.h i added this
Code:
private:
Ui::MainWindow *ui;
browser browser1;
};
and in "void" of the button which call the new form i added
The class generated by qt after i made the qt form(ui) called browser
Re: New form (ui) .problem :/
So the program does exactly what one expect it does.
You have a widget without parent, so it becomes a top level window.
The widget is empty, so the window is empty.
Assuming you don't want it empty, allow it to use the form you have created.
Just in case you didn't know: if you comment something out, it is not considered code by the compiler and not part of the functionality
Cheers,
_
Re: New form (ui) .problem :/
thank you..its my first time with qt and i just started c++ ... i used a lot visual studio .net etc
Of course i don't expect thecompiler to count comments as real code :) haha except if you decompile an application ...the decompiler can't realise the comments so it returns all comments as normal code :)
Re: New form (ui) .problem :/
Quote:
Originally Posted by
giannis1991
Of course i don't expect thecompiler to count comments as real code :) haha
:)
As I've already hinted in an earlier comment, the form's setupUi() method needs to be called.
Because that's where the content is created.
You have that inside a comment right now, so the widget stays empty.
Cheers,
_
Re: New form (ui) .problem :/
I am really sorry i just realised what you said me previously...yeah i made this uisetup as comment ,because every time i am coding and compiler gives me errors i just make ita s comment and if i find a solution then i deleted it.. so now this call gave me error and after i saw your new message i tested it again
with setupUi(this); i see this error
Code:
error: 'setupUi' was not declared in this scope
i check .cpp and i have a declaration under private: :confused::(
Re: New form (ui) .problem :/
Maybe you are calling it as
i.e. on the widget, instead of on the form object which has that method.
Cheers,
_
Re: New form (ui) .problem :/
Well,thank you a lot for all :) i just couldn't make it work :/ So i deleted my browser.h/browser.cpp/browser.ui ( i remembered that i had selected an empty form! ) so i thought it is a good idea to try the other one with the buttons! so i added a new with buttons .... i changed it to look like the previos browser.ui (qwebview,buttons etc) ..and voila!!! everything ok:)made my day :)