Results 1 to 4 of 4

Thread: Second Window properties

  1. #1
    Join Date
    Jul 2011
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1

    Default Second Window properties

    Hi.

    I'm trying to set a second window (called pir1) size and fill a background. i don't have problem to set this in first window (MainWindow).
    I created pir1.h, pir1.cpp and in MainWindow.cpp i have this (below code is in event filter):
    Qt Code:
    1. ...
    2. PIRWindow = new pir1();
    3. PIRWindow->show();
    4. PIRWindow->raise();
    5. PIRWindow->activateWindow();
    6. ...
    To copy to clipboard, switch view to plain text mode 
    I tried use a code that works with MainWindow so I created in pir1.cpp paint event with draw pixmap but it's didn't works.

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 268 Times in 268 Posts
    Wiki edits
    20

    Default Re: Second Window properties

    Quote Originally Posted by felo188 View Post
    but it's didn't works.
    Please explain what it is that does not work in great details.
    Otherwise a possible answer would be to adjust your Heisenberg Compensator to the correct compensation level.

  3. #3
    Join Date
    Jul 2011
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1

    Default Re: Second Window properties

    In my ui i have some buttons. When the button is clicked shows new window pir1 so showing new window is working. In MainWindow I set pixmap on background. I want to set background in the new window pir1 too.
    In MainWindow.cpp i have some code that is in eventFilter:
    Qt Code:
    1. ...
    2. PIRButton->animateClick();
    3. PIRWindow = new pir1();
    4. PIRWindow->show();
    5. PIRWindow->raise();
    6. PIRWindow->activateWindow();
    7. ...
    To copy to clipboard, switch view to plain text mode 
    In mainwindow.h:
    Qt Code:
    1. ...
    2. private:
    3. pir1 *PIRWindow;
    4. ...
    To copy to clipboard, switch view to plain text mode 
    I created new file pir1.cpp, pir1.h and pir1.ui just following in qt File->New File or Project->QT Designer Form Class.
    The background in MainWindow is set in paintEvent where is declared what and how should be displayed. And it's working as I wanted.
    In the pir1.cpp i try to display background in the same way so I declared paintEvent in the same way as in mainwindow class but it's don't working (the background isn't change to my pixmap).
    In pir1.cpp:
    Qt Code:
    1. ...
    2. void pir1::paintEvent(QPaintEvent *ev)
    3. {
    4. QPainter painter;
    5. background = new QPixmap("path to file");//path is correct
    6. QPixmap scaledPixMap = background->scaled(QSize(300,300));//I set window size in pir1.ui
    7. if(!background->isNull())
    8. {
    9. painter.drawPixmap(QPoint(0,0),scaledPixMap);
    10. }
    11. }
    12. ...
    To copy to clipboard, switch view to plain text mode 
    In pir1.h:
    Qt Code:
    1. ...
    2. private:
    3. QPixmap *background;
    4. ...
    To copy to clipboard, switch view to plain text mode 
    I don't know where I'm doing wrong.

  4. #4
    Join Date
    Jul 2011
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1

    Default Re: Second Window properties

    Enybody can help me? I don't know why I can add some buttons on second window pir1 but i'm not able to draw anythink.

    Edit:
    I found a solution The simplest thinks are the best.
    Qt Code:
    1. ...
    2. QPainter painter(this);
    3. ...
    To copy to clipboard, switch view to plain text mode 
    Last edited by felo188; 4th August 2011 at 10:39.

Similar Threads

  1. about properties
    By jajdoo in forum Newbie
    Replies: 5
    Last Post: 21st July 2011, 15:15
  2. Replies: 2
    Last Post: 17th February 2011, 13:30
  3. QObject, properties
    By Archa4 in forum Newbie
    Replies: 8
    Last Post: 11th February 2011, 09:05
  4. Properties Window
    By manti_madhu in forum Qt Programming
    Replies: 3
    Last Post: 30th October 2009, 10:30
  5. ViewPort Properties
    By Kapil in forum Qt Programming
    Replies: 6
    Last Post: 23rd March 2006, 12:57

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
  •  
Qt is a trademark of The Qt Company.