×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 30
  1. #1
    Registered User
    Join Date
    Dec 2010
    Location
    Delhi,INDIA
    Posts
    25

    Post Orientation problem

    According to the link ,I have done it vertically but I want to do the things horizontally as I have mentioned in the link but cant able to....Can somebody please help me....


    https://picasaweb.google.com/pradhikari88/NOKIA#
    Prajnaranjan Das

    e mail: prajnaranjan.das@gmail.com

  2. #2
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Orientation problem

    Please define what "It" is that you want to "do".

  3. #3
    Registered User
    Join Date
    Dec 2010
    Location
    Delhi,INDIA
    Posts
    25

    Re: Orientation problem

    Code:
    QWidget *bgWidget = new QWidget(this);
        bgWidget->setObjectName(QString::fromUtf8("bgWidget"));
        bgWidget->setStyleSheet("QWidget#bgWidget{background-image: url(:/images/Resource/n8_home_bg.jpg);}");
    
        QFont sansFont("Helvetica [Cronyx]", 15);
    
        // create buttons
        QPushButton *video = new QPushButton("VIDEOS");
        video->setObjectName(QString::fromUtf8("video"));
        video->setStyleSheet(QString::fromUtf8("QPushButton#video{\n"
                                               " border: 1px solid #333; \n"
                                               " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #0f3f5c, stop: 1 #0a354e);\n"
                                               "}\n"
                                               "\n"
                                               "QPushButton#video:pressed{\n"
                                              " border: 1px solid #333; \n"
                                              " color: #8a9fac; \n"
                                              " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #adcbd9, stop: 1 #fff);\n"
                                              "}"));
        video->setFixedHeight(80);
        video->setFont(sansFont);
    
        QPushButton *photo = new QPushButton("PHOTOS");
        photo->setObjectName(QString::fromUtf8("photo"));
        photo->setStyleSheet(QString::fromUtf8("QPushButton#photo{\n"
                                               " border: 1px solid #333; \n"
                                               " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #0f3f5c, stop: 1 #0a354e);\n"
                                               "}\n"
                                               "\n"
                                               "QPushButton#photo:pressed{\n"
                                              " border: 1px solid #333; \n"
                                              " color: #8a9fac; \n"
                                              " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #adcbd9, stop: 1 #fff);\n"
                                              "}"));
        photo->setFixedHeight(80);
        photo->setFont(sansFont);
    
        QPushButton *radio = new QPushButton("RADIO");
        radio->setObjectName(QString::fromUtf8("radio"));
        radio->setStyleSheet(QString::fromUtf8("QPushButton#radio{\n"
                                               " border: 1px solid #333; \n"
                                               " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #0f3f5c, stop: 1 #0a354e);\n"
                                               "}\n"
                                               "\n"
                                               "QPushButton#radio:pressed{\n"
                                               " color: #8a9fac; \n"
                                               " border: 1px solid #333; \n"
                                               " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #adcbd9, stop: 1 #fff);\n"
                                              "}"));
        radio->setFixedHeight(80);
        radio->setFont(sansFont);
    
        QPushButton *news = new QPushButton("NEWS");
        news->setObjectName(QString::fromUtf8("news"));
        news->setStyleSheet(QString::fromUtf8("QPushButton#news{\n"
                                               " border: 1px solid #333; \n"
                                               " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #0f3f5c, stop: 1 #0a354e);\n"
                                               "}\n"
                                               "\n"
                                               "QPushButton#news:pressed{\n"
                                              " border: 1px solid #333; \n"
                                              " color: #8a9fac; \n"
                                              " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #adcbd9, stop: 1 #fff);\n"
                                              "}"));
        news->setFixedHeight(80);
        news->setFont(sansFont);
    
        // Setup button layouts
        QVBoxLayout *buttonLayout = new QVBoxLayout(bgWidget);
        buttonLayout->setContentsMargins(0,150,0,3);
        buttonLayout->setSpacing(3);
        buttonLayout->addWidget(video);
        buttonLayout->addWidget(photo);
        buttonLayout->addWidget(radio);
        buttonLayout->addWidget(news);
    
        bgWidget->setLayout(buttonLayout);
    
        // Setup main layout
        QVBoxLayout *mainLayout = new QVBoxLayout;
        mainLayout->setContentsMargins(0,0,0,0);
        mainLayout->addWidget(bgWidget);
        this->setLayout(mainLayout);

    I have declared this code but I want that when I rotates it horizontally It should show like same as my horizontal view as I have given in my link but not able to.....
    Prajnaranjan Das

    e mail: prajnaranjan.das@gmail.com

  4. #4
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Orientation problem

    Since you're doing everything programmatically it's fairly easy. You need to first off determine what orientation you have and do different layouts accordingly. Then detect the orientation change (eg, QResizeEvent) and redo the layouts as needed.

  5. #5
    Registered User
    Join Date
    Dec 2010
    Location
    Delhi,INDIA
    Posts
    25

    Re: Orientation problem

    Thanks for your reply....Actually I want my QLabel should appear from top of the buttons to the lefthand side of the Buttons as I have mensioned the images in my link..My vertical and horizontal view are coming properly but I want It should appear like the horizontal image I have given....I have tried a lot in all the way I know but cant able to.....could you please tell me exactly what I have to do in this....
    Prajnaranjan Das

    e mail: prajnaranjan.das@gmail.com

  6. #6
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Orientation problem

    You have to do a DIFFERENT layout. First divide the screen in half and put the label in the left half. Put the buttons in another object in the right half. You can use either layouts or QWidgets to do this, depending on how much you want to control it vs having it done automatically.

    Eg, make the outer-most layout be a horizontal one, put the label in the left and a vertical layout for the buttons in the right. When orientation changes back you have to disconnect the widgets from their layouts, ditch the horizontal, and then reinsert everything in the vertical.

  7. #7
    Registered User
    Join Date
    Dec 2006
    Posts
    2,280

    Re: Orientation problem

    You can also lock the orientation to portrait or landscape. Symbian & Maemo both support this and the new Nokia Qt SDK 1.1 tech preview actually auto-generates the necessary code for you from the app wizard.

    You don't have move to the new SDK for it to work, you can cut and paste back to an older project if you want.

  8. #8
    Registered User
    Join Date
    Dec 2010
    Location
    Delhi,INDIA
    Posts
    25

    Re: Orientation problem

    I have done upto this and here how can I declare a function based on my screen size ....means if (screen size =someValue)
    stackedWidget->setCurrentIndex(0);

    can anybody please tell me how should I declare a function for this
    i'm getting my screen size like this...

    SIZE:: QSize(360, 640)
    SIZE:: QSize(640, 360)


    Code:
    #include <QtGui/QVBoxLayout>
    #include <QtGui/QPushButton>
    #include <QtGui>
    #include <QResizeEvent>
    
    #include "rotate.h"
    
    
    Rotate::Rotate(QWidget *parent) :
        QWidget(parent)
    
    {
    
        QWidget *vWidget = new QWidget;
        vWidget->setObjectName(QString::fromUtf8("vWidget"));
    
        QPushButton *video1 = new QPushButton("VIDEOS");
        video1->setObjectName(QString::fromUtf8("video1"));
        video1->setFixedHeight(80);
    
        QPushButton *photo1 = new QPushButton("PHOTOS");
        photo1->setObjectName(QString::fromUtf8("photo1"));
        photo1->setFixedHeight(80);
    
        QPushButton *radio1 = new QPushButton("RADIO");
        radio1->setObjectName(QString::fromUtf8("radio1"));
        radio1->setFixedHeight(80);
    
        QPushButton *news1 = new QPushButton("NEWS");
        news1->setObjectName(QString::fromUtf8("news"));
        news1->setFixedHeight(80);
    
    
        QVBoxLayout *buttonLayout1 = new QVBoxLayout(vWidget);
        buttonLayout1->setContentsMargins(0,150,0,3);
        buttonLayout1->setSpacing(3);
        buttonLayout1->addWidget(video1);
        buttonLayout1->addWidget(photo1);
        buttonLayout1->addWidget(radio1);
        buttonLayout1->addWidget(news1);
        vWidget->setLayout(buttonLayout1);
    
    
        /////////////////////////////////////////////////////////
    
    
        QWidget *hWidget = new QWidget;
    
        QLabel *label = new QLabel;
    
        QPushButton *video2 = new QPushButton("VIDEOS");
        video2->setObjectName(QString::fromUtf8("video2"));
        video2->setFixedHeight(60);
    
        QPushButton *photo2 = new QPushButton("PHOTOS");
        photo2->setObjectName(QString::fromUtf8("photo2"));
        photo2->setFixedHeight(60);
    
        QPushButton *radio2 = new QPushButton("RADIO");
        radio2->setObjectName(QString::fromUtf8("radio2"));
        radio2->setFixedHeight(60);
    
        QPushButton *news2 = new QPushButton("NEWS");
        news2->setObjectName(QString::fromUtf8("news2"));
        news2->setFixedHeight(60);
    
        QVBoxLayout *buttonLayout2 = new QVBoxLayout;
        buttonLayout2->addWidget(video2);
        buttonLayout2->addWidget(photo2);
        buttonLayout2->addWidget(radio2);
        buttonLayout2->addWidget(news2);
    
        QPushButton *home = new QPushButton("HOME");
        QPushButton *back = new QPushButton("BACK");
    
        QHBoxLayout *hLayout2 = new QHBoxLayout;
        hLayout2->addWidget(home);
        hLayout2->addWidget(back);
    
        QVBoxLayout *vLayout2 = new QVBoxLayout;
        vLayout2->addWidget(label);
        vLayout2->addLayout(hLayout2);
    
    
        QHBoxLayout *hLayout3 = new QHBoxLayout(hWidget);
        hLayout3->addLayout(vLayout2);
        hLayout3->addLayout(buttonLayout2);
        hWidget->setLayout(hLayout3);
    
    
        ///////////////////////////////////////////////////////////////
    
    
        QStackedWidget *stackedWidget = new QStackedWidget;
        stackedWidget->addWidget(vWidget);
        stackedWidget->addWidget(hWidget);
    
        QVBoxLayout *layout = new QVBoxLayout;
        layout->addWidget(stackedWidget);
        setLayout(layout);
    
        stackedWidget->setCurrentIndex(1);
    }
    
    
    
    void Rotate::resizeEvent(QResizeEvent *event)
    {
       qDebug()<<"SIZE::"<<qApp->desktop()->size();
    }
    Prajnaranjan Das

    e mail: prajnaranjan.das@gmail.com

  9. #9
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Orientation problem

    Well, first off you need to declare (but not create) all (or at least some) of your widget variables in your .h file, so that they can be accessed from outside the constructor.

    Then I'd use event ->size(), something like:

    void Rotate::resizeEvent(QResizeEvent* event) {
    QSize size = event ->size();
    bool landscape = (size.width() > size.height();
    this ->rotate(landscape);
    super ->resizeEvent(event);
    }

    void Rotate::rotate(bool) would remove your widgets from their current layouts, set up the new layouts, then reinsert the widgets. Would probably be wise to keep a "currentRotation" value in your object to remember if you're landscape or portrait, and compare that to the new rotation at the start of rotate(). Not only do you not want to do unnecessary work, but the logic to remove widgets from layouts probably needs to know which orientation is current.

  10. #10
    Regular Contributor
    Join Date
    Jan 2011
    Posts
    122

    Re: Orientation problem

    Quote Originally Posted by Sorcery-ltd View Post
    You can also lock the orientation to portrait or landscape. Symbian & Maemo both support this and the new Nokia Qt SDK 1.1 tech preview actually auto-generates the necessary code for you from the app wizard.

    You don't have move to the new SDK for it to work, you can cut and paste back to an older project if you want.
    @Sorcery-ltd, I need what youre saying here. How should I lock the orientation in Symbian^3? I have screens that need to be displayed on landscape mode ONLY, and others, portrait mode only so I don't want to layout the widgets on the form to have the sizes fixed. I can't find a thread that is specific to Symbian^3 and C++ regarding this. Please help. Thanks!

  11. #11
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

  12. #12
    Regular Contributor
    Join Date
    Jan 2011
    Posts
    122

    Re: Orientation problem

    It won't satisfy the #ifdef Q_OS_SYMBIAN, I'm using Qt 4.7.1 or will it not detect it if I'm using the Symbian^3 simulator?

  13. #13
    Registered User
    Join Date
    Dec 2010
    Location
    Delhi,INDIA
    Posts
    25

    Re: Orientation problem

    thanks danhicksbyron for your reply

    I did it in another way....Its working......

    Code:
    void Rotate::resizeEvent(QResizeEvent *event)
    {
       qDebug()<<"SIZE::"<<qApp->desktop()->size();
       if(qApp->desktop()->size()== QSize(360,640))
       {
           stackedWidget->setCurrentIndex(0);
       }
       else
       {
           stackedWidget->setCurrentIndex(1);
       }
    }
    Prajnaranjan Das

    e mail: prajnaranjan.das@gmail.com

  14. #14
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Orientation problem

    The simulator isn't Symbian. AFAIK, you can't "fix" orientation on the simulator.

  15. #15
    Registered User
    Join Date
    Dec 2006
    Posts
    2,280

    Re: Orientation problem

    Correct, you can't fix the orientation on the simulator, but then you only turn the simulator through an external control, so you can set the orientation before launch.

    Without seeing your app I'll go out on a limb and say that any app which relies on the user switching orientation for different screens has a very broken UX. Is there not some other way?

    It is indeed possible to use the orientation "locking" code multiple times to "re-lock" the orientation in another direction but I'd seriously advise against doing it from a usability perspective.

Similar Threads

  1. Orientation problem
    By AndreAhmed in forum Symbian
    Replies: 9
    Last Post: 2010-04-14, 12:32
  2. Orientation problem
    By keerthi.ck06 in forum Symbian User Interface
    Replies: 3
    Last Post: 2009-10-08, 13:03
  3. portrait orientation and landscape orientation in N96
    By videoFx in forum [Archived] Flash Lite on Nokia Devices
    Replies: 0
    Last Post: 2009-05-20, 15:13
  4. Orientation problem
    By remesh in forum Symbian User Interface
    Replies: 1
    Last Post: 2008-11-24, 13:30
  5. Orientation Problem
    By memsmusik1 in forum Symbian
    Replies: 4
    Last Post: 2008-07-25, 17:18

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×