I want to do some changes on screen rotation , the code of the method that is supposed to handle such event is taken from here
http://www.developer.nokia.com/Community/Wiki/CS001437_-_Listening_for_screen_orientation_changes_in_Qt
edit: I have a scroll area , and its getting of border on rotation how can i adjust its size?so it could fit the screen plz check the event handler below this my whole code :
//FORM1.CPP
#include "form1.h"
#include "ui_form1.h"
#include "form.h"
#include "ui_form.h"
#include <QResizeEvent>
Form1::Form1(QWidget *parent) :
QWidget(parent),
ui(new Ui::Form1)
{
ui->setupUi(this);
}
开发者_StackOverflowForm1::~Form1()
{
delete ui;
}
//the method that is supposed to handle such event
void Form1::resizeEvent (QResizeEvent* event)
{
QWidget::resizeEvent(event);
ui->textBrowser->setText("karim");
}
I got this error:
\Users\user\Desktop\karim\Qt\Project\form1.cpp:31: error: 'QMyWidget' has not been declared
Please note that I didn't do anything else this is my whole code ... Can you please tell me whats wrong or what am not getting ?
Please be specific I would appreciate that ...
You must create slot
connect(qApp->desktop(), SIGNAL(resized(int)), this, SLOT(onResized(int)));
and implement it like:
void Widget::onResized(int)
{
QDesktopWidget* screen = qApp->desktop();
QSize displaySize;
if (screen) {
displaySize = screen->screenGeometry().size();
if (displaySize != this->size()) {
this->resize(displaySize);
}
}
}
I do not see any reference to your QMyWidget
class other than the below line. May be I'm missing something. But if you have defined your QMyWidget
class elsewhere, you atleast need to include the header.
void QMyWidget::resizeEvent(QResizeEvent* event)
{
ui->labelk->setText("blabla");
}
May be you meant this instead of the above:
void Form1::resizeEvent(QResizeEvent* event)
{
ui->labelk->setText("blabla");
}
Update to the comment: You can try doing this.
void Form1::resizeEvent(QResizeEvent* event)
{
// call the base class for the default behavior
QWidget::resizeEvent(event);
// Add your custom changes here
ui->labelk->setText("blabla");
}
精彩评论