Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Problem in display while rotating my Qt Simulator
Forum Updated to NodeBB v4.3 + New Features

Problem in display while rotating my Qt Simulator

Scheduled Pinned Locked Moved Mobile and Embedded
7 Posts 3 Posters 4.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    prajnaranjan.das
    wrote on last edited by
    #1

    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...

    Prajnaranjan Das

    e mail: prajnaranjan.das@gmail.com

    1 Reply Last reply
    0
    • A Offline
      A Offline
      anselmolsm
      wrote on last edited by
      #2

      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 :-)

      Anselmo L. S. Melo (anselmolsm)

      1 Reply Last reply
      0
      • P Offline
        P Offline
        prajnaranjan.das
        wrote on last edited by
        #3

        @
        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]

        Prajnaranjan Das

        e mail: prajnaranjan.das@gmail.com

        1 Reply Last reply
        0
        • ? This user is from outside of this forum
          ? This user is from outside of this forum
          Guest
          wrote on last edited by
          #4

          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 recognized

          the 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.

          1 Reply Last reply
          0
          • J Offline
            J Offline
            JacquesBaniaque
            wrote on last edited by
            #5

            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 alignment

            QPushButton* 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)

            1 Reply Last reply
            0
            • P Offline
              P Offline
              prajnaranjan.das
              wrote on last edited by
              #6

              Its showing setCentralWidget was not diclared in this scope...
              How to fix it ....

              Prajnaranjan Das

              e mail: prajnaranjan.das@gmail.com

              1 Reply Last reply
              0
              • ? This user is from outside of this forum
                ? This user is from outside of this forum
                Guest
                wrote on last edited by
                #7

                [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]

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved