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. QFileDialog in QStyledItemDelegate

QFileDialog in QStyledItemDelegate

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.9k 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.
  • G Offline
    G Offline
    gabor53
    wrote on last edited by
    #1

    Hi,
    I have the following code to open a QFileDialog in a delegate (to replace an already existing image in QStandardItemModel):

        fileName = fileDialog->getOpenFileName(this,
                                               tr("Finding Friend's Image"),sPath, tr("Image Files (*.png *.jpg *.bmp)"));
    

    This line already works in a QDialog, but in the delegate 'this' is underlined and gives me the following message: cannot initialize a parameter of type 'QWidget*' with an rvalue of type 'myDelegate*'.
    How can I avoid this error?
    Thank you.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      It means it do not want a Delegate * as QWidget * pointer for parent.

      QString QFileDialog::getOpenFileName(QWidget *parent = Q_NULLPTR

      So to avoid it simply pass Q_NULLPTR for "this"

      G 1 Reply Last reply
      2
      • mrjjM mrjj

        Hi
        It means it do not want a Delegate * as QWidget * pointer for parent.

        QString QFileDialog::getOpenFileName(QWidget *parent = Q_NULLPTR

        So to avoid it simply pass Q_NULLPTR for "this"

        G Offline
        G Offline
        gabor53
        wrote on last edited by
        #3

        @mrjj
        Thank you. It worked.

        1 Reply Last reply
        0

        • Login

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