Results 1 to 2 of 2

Thread: How to implement QGLFormat with QGLContext

  1. #1
    Join Date
    Aug 2011
    Posts
    5
    Platforms
    Unix/X11

    Default How to implement QGLFormat with QGLContext

    What I'd like to know is how pass my QGLFormat object to QGLContext?

    When I try to do this:

    Qt Code:
    1. QGLFormat mFormat = QGLFormat( QGL::DepthBuffer | QGL::AlphaChannel );
    2.  
    3. QGLContext mContext = QGLContext( mFormat );
    To copy to clipboard, switch view to plain text mode 

    I get this error:

    Qt Code:
    1. error: 'QGLContext::QGLContext(const QGLContext&)' is private
    To copy to clipboard, switch view to plain text mode 

    Using Qt Creator with Windows 7.

    What is wrong here?

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: How to implement QGLFormat with QGLContext

    Change
    Qt Code:
    1. QGLContext mContext = QGLContext( mFormat );
    To copy to clipboard, switch view to plain text mode 
    to
    Qt Code:
    1. QGLContext mContext( mFormat );
    To copy to clipboard, switch view to plain text mode 
    I think compiler "thinks" you want to use copy-constructor, which is private. But in fact the copy-constructor will not be used in this case. Look here:
    Qt Code:
    1. #include <iostream>
    2.  
    3. class T
    4. {
    5. public:
    6. T(){
    7. std::cout << "T()\n";
    8. }
    9. T(const T&){
    10. std::cout << "T(const T&)\n";
    11. }
    12. T(int){
    13. std::cout << "T(int)\n";
    14. }
    15. T& operator=(const T& t){
    16. std::cout << "T& operator\n";
    17. }
    18. };
    19.  
    20. int main(){
    21. T t = T(10);
    22. return 10;
    23. }
    To copy to clipboard, switch view to plain text mode 
    This should print T(int), which means the copy-constructor is not used. But this:
    Qt Code:
    1. #include <iostream>
    2.  
    3. class T
    4. {
    5. public:
    6. T(){
    7. std::cout << "T()\n";
    8. }
    9. T(int){
    10. std::cout << "T(int)\n";
    11. }
    12. T& operator=(const T& t){
    13. std::cout << "T& operator\n";
    14. }
    15. private:
    16. T(const T&){
    17. std::cout << "T(const T&)\n";
    18. }
    19. };
    20.  
    21. int main(){
    22. T t = T(10);
    23. return 10;
    24. }
    To copy to clipboard, switch view to plain text mode 
    does not compile:
    test.cpp: In function 'int main()':
    test.cpp:54:3: error: 'T::T(const T&)' is private
    test.cpp:60:12: error: within this context
    (tested with g++ 4.5.2)

Similar Threads

  1. QGLWidget & QGLContext & QThread
    By eye51 in forum Qt Programming
    Replies: 3
    Last Post: 3rd April 2011, 12:26
  2. QT4.7 & QGLFormat::CoreProfile & shaders
    By saraksh in forum Qt Programming
    Replies: 3
    Last Post: 27th December 2010, 22:04
  3. QGLContext problems
    By bhuang in forum Qt Programming
    Replies: 1
    Last Post: 25th August 2010, 08:18
  4. QGLContext Issue
    By parmar in forum Qt Programming
    Replies: 5
    Last Post: 18th June 2010, 10:25
  5. overlay QGLContext
    By showhand in forum Qt Programming
    Replies: 3
    Last Post: 10th April 2007, 16:51

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.