Problem in display while rotating my Qt Simulator
-
In Qt Simulator I have added four pushButton and an Image above it but when I am rotating my device all the things are not coming properly....I can only view image and one button below it in which the other three pushbuttons are not getting displayed...Please help me...
-
How did you determine the position of each widget? Are you using a layout?
Post the relevant part of your code, so it'll be easier for us to help you :-) -
@
QLabel *lbl = new QLabel;
QPixmap pixmap(QPixmap::fromImage(QImage(":/images/photos/nokia2.bmp")));
lbl->setPixmap(pixmap);
lbl->alignment();videoButton = new QPushButton(tr("&VIDEO"));
videoButton->show();
photoButton = new QPushButton(tr("&PHOTO"));
photoButton->show();
radioButton = new QPushButton(tr("&RADIO"));
radioButton->show();
newsButton = new QPushButton(tr("&NEWS"));
newsButton->show();QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(lbl,0,0);
layout->addWidget(videoButton,1,0);
layout->addWidget(photoButton,2,0);
layout->addWidget(radioButton,3,0);
layout->addWidget(newsButton,4,0);
layout->addStretch();
setLayout(layout);@
[edit: fixed code tag / chetankjain]
-
Hi Prajnaranjan,
Slight correction, its Qt and not QT (quick time)
Also recommend enclosing code blocks with the @ tag, makes reading easier and Qt keywords are recognizedthe real estate available in portrait is different from the one in landscape, you will have to adjust your layout/component positions accordingly to make your UI look better.
-
Hi Prajnaranjan,
I'm not how do You use your container widget (the one that holds label and all the buttons).
I used QMainWindow inherited class and made it visible with showMaximized()
In it's constructor i put your code (with modifications):@
QLabel *lbl = new QLabel;
// i commented pixmap because i did not have an image...
//QPixmap pixmap(QPixmap::fromImage(QImage(":/images/photos/nokia2.bmp")));
// ... i used text insted
lbl->setText("<Image goes here>");
//lbl->setPixmap(pixmap);
// lbl->alignment(); // this does nothing, it only returns current labels alignment, you don' need it here
lbl->setAlignment(Qt::AlignCenter); // on the other hand this sets the alignmentQPushButton* videoButton = new QPushButton(tr("&VIDEO")); //videoButton->show(); //you don't need to call this QPushButton* photoButton = new QPushButton(tr("&PHOTO")); //photoButton->show(); //you don't need to call this QPushButton* radioButton = new QPushButton(tr("&RADIO")); //radioButton->show(); //you don't need to call this QPushButton* newsButton = new QPushButton(tr("&NEWS")); //newsButton->show(); //you don't need to call this QWidget *centralWidget = new QWidget(this); // add a centralwidget to main window, it holds all the widgets displayed in MainWiwndow setCentralWidget(centralWidget); QVBoxLayout *layout = new QVBoxLayout; // You probably don't want the second and third parameter in addWidget() // second parameter is NOT row number where you insert your widget //layout->addWidget(lbl, 0, 0); layout->addWidget(lbl); layout->addWidget(videoButton); layout->addWidget(photoButton); layout->addWidget(radioButton); layout->addWidget(newsButton); layout->addStretch(); centralWidget->setLayout(layout); //set layout on central widget, not on MainWindow
@
This modified code works fine, all butons are visible and a label with text above them. Rotating in both orientations works fine as well.
I just had a second thought about your problem. Maybe your buttons are not visible... because they come out of the screen because the image is too big?
In that situation you should either make your image shrink or use QScrollArea as a central widget (it will show scroll bars when widgets get off the screen) -
Its showing setCentralWidget was not diclared in this scope...
How to fix it .... -
[quote author="Prajnaranjan Das" date="1292220681"]Its showing setCentralWidget was not diclared in this scope...
How to fix it ....[/quote]Prajnaranjan, I think you missed this part ...
[quote author="JacquesBaniaque" date="1292064039"]...
I used QMainWindow inherited class and made it visible with showMaximized()
...
[/quote]