Results 1 to 2 of 2

Thread: strange problem creating a 7-segment clock

  1. #1
    Join Date
    Jan 2012
    Posts
    15
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default strange problem creating a 7-segment clock

    hello everybody
    I'm creating a simple application that should be a 7 segment clock, everything works ok when I try this codesnippet
    Qt Code:
    1. QString hour=QString::number(time.currentTime().hour());
    2. QString min=QString::number(time.currentTime().minute());
    3. QString sec=QString::number(time.currentTime().second());
    4. scene->clear();
    5. for(int i=0;i<6;i++)
    6. {
    7. if(i%2==0 && i>0)
    8. this->designPoints(i);//I design the dots so that the clock looks something like this 00:00:00
    9. QString appoggio;
    10. if(i==0 || i ==1)
    11. appoggio=ImpostaAppoggio(i,hour);//sets the value of appoggio
    12. if(i==2 || i==3 )
    13. appoggio=ImpostaAppoggio(i,min);
    14. if(i==4 || i ==5)
    15. appoggio=ImpostaAppoggio(i,sec);
    16. DisegnaNum(appoggio,i);//I design the seven segments
    To copy to clipboard, switch view to plain text mode 
    but when I try this
    Qt Code:
    1. for(int j=0;j<1000;j++)
    2. {
    3. QString hour=QString::number(time.currentTime().hour());
    4. QString min=QString::number(time.currentTime().minute());
    5. QString sec=QString::number(time.currentTime().second());
    6. scene->clear();
    7. for(int i=0;i<6;i++)
    8. {
    9. if(i%2==0 && i>0)
    10. this->designPoints(i);
    11. QString appoggio;
    12. if(i==0 || i ==1)
    13. appoggio=ImpostaAppoggio(i,hour);
    14. if(i==2 || i==3 )
    15. appoggio=ImpostaAppoggio(i,min);
    16. if(i==4 || i ==5)
    17. appoggio=ImpostaAppoggio(i,sec);
    18. DisegnaNum(appoggio,i);
    19. }
    20. }
    To copy to clipboard, switch view to plain text mode 
    no errors or warning occur but no window is showing up and I can't figure out what's going wrong! can someone help?
    thank's

  2. #2
    Join Date
    Jan 2012
    Location
    Dortmund, Germany
    Posts
    159
    Thanks
    69
    Thanked 10 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: strange problem creating a 7-segment clock

    I can't really see what you want to achieve with the for loop. You change and change and change the clock again and again - but you don't return from the routine to let the results be displayed.

    Actually I think you might want to have this routine be called every second to update your clock and let the computer do its homework for the rest of the second.
    This should be possible with the QTimer, read here about it. You need to put the routine into a public slot (defined that way in the header file) in order to connect the timer's signal to it (e.g. in MainWindow).

    I'm not sure if I explained this correctly or if I even understood your intention well enough, though.
    Last edited by sedi; 28th April 2012 at 01:32.

  3. The following user says thank you to sedi for this useful post:

    sax94 (30th April 2012)

Similar Threads

  1. segment fault with any QT GUI program
    By earth in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 22nd March 2011, 23:29
  2. Draw directly from a memory segment
    By 25an in forum Qt Programming
    Replies: 1
    Last Post: 28th November 2009, 13:04
  3. Segment fault using a Qt plugin with QTabWidget
    By tarod in forum Qt Programming
    Replies: 2
    Last Post: 14th July 2009, 10:27
  4. Segment fault when using Q3ListBox and QFile
    By hiuao in forum Qt Programming
    Replies: 8
    Last Post: 12th May 2007, 11:51
  5. how to write a structure in a shared mem segment.
    By nass in forum General Programming
    Replies: 9
    Last Post: 26th September 2006, 13:11

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.