Results 1 to 7 of 7

Thread: Orientation Problem

  1. #1
    Join Date
    Dec 2010
    Posts
    34
    Qt products
    Qt4
    Platforms
    Windows

    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#
    Regards:

    Prajnaranjan Das
    e mail: prajnaranjan.das@gmail.com

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Orientation Problem

    Can somebody please help me....
    Maybe, if you explain what the problem is, post the code etc.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Dec 2010
    Posts
    34
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Orientation Problem

    Qt Code:
    1. QWidget *bgWidget = new QWidget(this);
    2. bgWidget->setObjectName(QString::fromUtf8("bgWidget"));
    3. bgWidget->setStyleSheet("QWidget#bgWidget{background-image: url(:/images/Resource/n8_home_bg.jpg);}");
    4.  
    5. QFont sansFont("Helvetica [Cronyx]", 15);
    6.  
    7. // create buttons
    8. QPushButton *video = new QPushButton("VIDEOS");
    9. video->setObjectName(QString::fromUtf8("video"));
    10. video->setStyleSheet(QString::fromUtf8("QPushButton#video{\n"
    11. " border: 1px solid #333; \n"
    12. " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #0f3f5c, stop: 1 #0a354e);\n"
    13. "}\n"
    14. "\n"
    15. "QPushButton#video:pressed{\n"
    16. " border: 1px solid #333; \n"
    17. " color: #8a9fac; \n"
    18. " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #adcbd9, stop: 1 #fff);\n"
    19. "}"));
    20. video->setFixedHeight(80);
    21. video->setFont(sansFont);
    22.  
    23. QPushButton *photo = new QPushButton("PHOTOS");
    24. photo->setObjectName(QString::fromUtf8("photo"));
    25. photo->setStyleSheet(QString::fromUtf8("QPushButton#photo{\n"
    26. " border: 1px solid #333; \n"
    27. " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #0f3f5c, stop: 1 #0a354e);\n"
    28. "}\n"
    29. "\n"
    30. "QPushButton#photo:pressed{\n"
    31. " border: 1px solid #333; \n"
    32. " color: #8a9fac; \n"
    33. " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #adcbd9, stop: 1 #fff);\n"
    34. "}"));
    35. photo->setFixedHeight(80);
    36. photo->setFont(sansFont);
    37.  
    38. QPushButton *radio = new QPushButton("RADIO");
    39. radio->setObjectName(QString::fromUtf8("radio"));
    40. radio->setStyleSheet(QString::fromUtf8("QPushButton#radio{\n"
    41. " border: 1px solid #333; \n"
    42. " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #0f3f5c, stop: 1 #0a354e);\n"
    43. "}\n"
    44. "\n"
    45. "QPushButton#radio:pressed{\n"
    46. " color: #8a9fac; \n"
    47. " border: 1px solid #333; \n"
    48. " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #adcbd9, stop: 1 #fff);\n"
    49. "}"));
    50. radio->setFixedHeight(80);
    51. radio->setFont(sansFont);
    52.  
    53. QPushButton *news = new QPushButton("NEWS");
    54. news->setObjectName(QString::fromUtf8("news"));
    55. news->setStyleSheet(QString::fromUtf8("QPushButton#news{\n"
    56. " border: 1px solid #333; \n"
    57. " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #0f3f5c, stop: 1 #0a354e);\n"
    58. "}\n"
    59. "\n"
    60. "QPushButton#news:pressed{\n"
    61. " border: 1px solid #333; \n"
    62. " color: #8a9fac; \n"
    63. " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #adcbd9, stop: 1 #fff);\n"
    64. "}"));
    65. news->setFixedHeight(80);
    66. news->setFont(sansFont);
    67.  
    68. // Setup button layouts
    69. QVBoxLayout *buttonLayout = new QVBoxLayout(bgWidget);
    70. buttonLayout->setContentsMargins(0,150,0,3);
    71. buttonLayout->setSpacing(3);
    72. buttonLayout->addWidget(video);
    73. buttonLayout->addWidget(photo);
    74. buttonLayout->addWidget(radio);
    75. buttonLayout->addWidget(news);
    76.  
    77. bgWidget->setLayout(buttonLayout);
    78.  
    79. // Setup main layout
    80. QVBoxLayout *mainLayout = new QVBoxLayout;
    81. mainLayout->setContentsMargins(0,0,0,0);
    82. mainLayout->addWidget(bgWidget);
    83. this->setLayout(mainLayout);
    To copy to clipboard, switch view to plain text mode 
    Regards:

    Prajnaranjan Das
    e mail: prajnaranjan.das@gmail.com

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Orientation Problem

    So just change from QVBoxLayout to QHBoxLayout.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Dec 2010
    Posts
    34
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Orientation Problem

    Thanks for your reply....I tried but not working....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....
    Regards:

    Prajnaranjan Das
    e mail: prajnaranjan.das@gmail.com

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Orientation Problem

    .I tried but not working..
    Show your code (that is not working)
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  7. #7
    Join Date
    Dec 2010
    Posts
    34
    Qt products
    Qt4
    Platforms
    Windows

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


    Qt Code:
    1. #include <QtGui/QVBoxLayout>
    2. #include <QtGui/QPushButton>
    3. #include <QtGui>
    4. #include <QResizeEvent>
    5.  
    6. #include "rotate.h"
    7.  
    8.  
    9. Rotate::Rotate(QWidget *parent) :
    10. QWidget(parent)
    11.  
    12. {
    13.  
    14. QWidget *vWidget = new QWidget;
    15. vWidget->setObjectName(QString::fromUtf8("vWidget"));
    16.  
    17. QPushButton *video1 = new QPushButton("VIDEOS");
    18. video1->setObjectName(QString::fromUtf8("video1"));
    19. video1->setFixedHeight(80);
    20.  
    21. QPushButton *photo1 = new QPushButton("PHOTOS");
    22. photo1->setObjectName(QString::fromUtf8("photo1"));
    23. photo1->setFixedHeight(80);
    24.  
    25. QPushButton *radio1 = new QPushButton("RADIO");
    26. radio1->setObjectName(QString::fromUtf8("radio1"));
    27. radio1->setFixedHeight(80);
    28.  
    29. QPushButton *news1 = new QPushButton("NEWS");
    30. news1->setObjectName(QString::fromUtf8("news"));
    31. news1->setFixedHeight(80);
    32.  
    33.  
    34. QVBoxLayout *buttonLayout1 = new QVBoxLayout(vWidget);
    35. buttonLayout1->setContentsMargins(0,150,0,3);
    36. buttonLayout1->setSpacing(3);
    37. buttonLayout1->addWidget(video1);
    38. buttonLayout1->addWidget(photo1);
    39. buttonLayout1->addWidget(radio1);
    40. buttonLayout1->addWidget(news1);
    41. vWidget->setLayout(buttonLayout1);
    42.  
    43.  
    44. /////////////////////////////////////////////////////////
    45.  
    46.  
    47. QWidget *hWidget = new QWidget;
    48.  
    49. QLabel *label = new QLabel;
    50.  
    51. QPushButton *video2 = new QPushButton("VIDEOS");
    52. video2->setObjectName(QString::fromUtf8("video2"));
    53. video2->setFixedHeight(60);
    54.  
    55. QPushButton *photo2 = new QPushButton("PHOTOS");
    56. photo2->setObjectName(QString::fromUtf8("photo2"));
    57. photo2->setFixedHeight(60);
    58.  
    59. QPushButton *radio2 = new QPushButton("RADIO");
    60. radio2->setObjectName(QString::fromUtf8("radio2"));
    61. radio2->setFixedHeight(60);
    62.  
    63. QPushButton *news2 = new QPushButton("NEWS");
    64. news2->setObjectName(QString::fromUtf8("news2"));
    65. news2->setFixedHeight(60);
    66.  
    67. QVBoxLayout *buttonLayout2 = new QVBoxLayout;
    68. buttonLayout2->addWidget(video2);
    69. buttonLayout2->addWidget(photo2);
    70. buttonLayout2->addWidget(radio2);
    71. buttonLayout2->addWidget(news2);
    72.  
    73. QPushButton *home = new QPushButton("HOME");
    74. QPushButton *back = new QPushButton("BACK");
    75.  
    76. QHBoxLayout *hLayout2 = new QHBoxLayout;
    77. hLayout2->addWidget(home);
    78. hLayout2->addWidget(back);
    79.  
    80. QVBoxLayout *vLayout2 = new QVBoxLayout;
    81. vLayout2->addWidget(label);
    82. vLayout2->addLayout(hLayout2);
    83.  
    84.  
    85. QHBoxLayout *hLayout3 = new QHBoxLayout(hWidget);
    86. hLayout3->addLayout(vLayout2);
    87. hLayout3->addLayout(buttonLayout2);
    88. hWidget->setLayout(hLayout3);
    89.  
    90.  
    91. ///////////////////////////////////////////////////////////////
    92.  
    93.  
    94. QStackedWidget *stackedWidget = new QStackedWidget;
    95. stackedWidget->addWidget(vWidget);
    96. stackedWidget->addWidget(hWidget);
    97.  
    98. QVBoxLayout *layout = new QVBoxLayout;
    99. layout->addWidget(stackedWidget);
    100. setLayout(layout);
    101.  
    102. stackedWidget->setCurrentIndex(1);
    103. }
    104.  
    105.  
    106.  
    107. void Rotate::resizeEvent(QResizeEvent *event)
    108. {
    109. qDebug()<<"SIZE::"<<qApp->desktop()->size();
    110. }
    To copy to clipboard, switch view to plain text mode 
    Regards:

    Prajnaranjan Das
    e mail: prajnaranjan.das@gmail.com

Similar Threads

  1. QLabel orientation
    By smacchia in forum Qt Programming
    Replies: 1
    Last Post: 18th November 2010, 15:56
  2. Screen orientation
    By Tomasz in forum Qt for Embedded and Mobile
    Replies: 6
    Last Post: 31st August 2010, 09:47
  3. Change QTableView orientation
    By r2d2u2 in forum Qt Programming
    Replies: 2
    Last Post: 31st May 2010, 10:30
  4. QWidget orientation
    By Valheru in forum Qt Programming
    Replies: 8
    Last Post: 19th August 2008, 17:20
  5. Vertical Orientation of Text.
    By ashukla in forum Qt Programming
    Replies: 9
    Last Post: 28th January 2008, 12:40

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.