Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]c2568 unable to reolve overload == while trying to setup a print function
Forum Update on Monday, May 27th 2025

[SOLVED]c2568 unable to reolve overload == while trying to setup a print function

Scheduled Pinned Locked Moved General and Desktop
printingunable to resolc2568
3 Posts 2 Posters 1.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Suroh6
    wrote on 11 Apr 2015, 20:52 last edited by Suroh6 4 Dec 2015, 12:39
    #1

    Trying to setup a really basic printing function, the code I've got so far is as follows.

           void PrintMenu::on_pushButton_2_clicked()
    {
     QTextDocument* Document = ui->textBrowser->document();
    QPrinter Printer;
    QPrintDialog* printdialog = new QPrintDialog(&Printer, this);
    
    if (printdialog->exec()==&QPrintDialog::accepted)
    // Compiling fails here it says c2568 unable to resolve function overload == any suggestions as to how I could fix this? 
      {
        Document->print(&Printer);
      } 
    }
    
    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on 11 Apr 2015, 21:21 last edited by Chris Kawa 4 Nov 2015, 21:22
      #2

      Should be:

      if (printdialog->exec() == QPrintDialog::Accepted) 
      

      notice the capital A and no &.
      Accepted is an enum value and accepted is a signal (a function), so your code tried to compare an int (the return value of exec()) and a function pointer, which there is no operator== for.

      Btw. It's usually easier to allocate dialogs like that on the stack. The above code leaks memory (printdialog instance).

      S 1 Reply Last reply 12 Apr 2015, 11:58
      0
      • C Chris Kawa
        11 Apr 2015, 21:21

        Should be:

        if (printdialog->exec() == QPrintDialog::Accepted) 
        

        notice the capital A and no &.
        Accepted is an enum value and accepted is a signal (a function), so your code tried to compare an int (the return value of exec()) and a function pointer, which there is no operator== for.

        Btw. It's usually easier to allocate dialogs like that on the stack. The above code leaks memory (printdialog instance).

        S Offline
        S Offline
        Suroh6
        wrote on 12 Apr 2015, 11:58 last edited by
        #3

        @Chris-Kawa Thanks :)

        1 Reply Last reply
        0

        1/3

        11 Apr 2015, 20:52

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved