Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User lipos123's Avatar
    Join Date
    Jan 2011
    Posts
    192
    HI,

    I have a little problem when focusing on a scrollArea,
    i am putting labels in a vertical layout, and then put this layout in the scroll area.
    but i am loosing the focus on the scroll area.
    Any help concerning my issue????
    find below my coding, and thank you.
    Best Regards,

    for ( index_of_label = 0;index_of_label<50;index_of_label++)
    {
    myLabel[index_of_label] = new QLabel(myText,ui->scrollAreaWidgetContents );
    myLabel[index_of_label]->setStyleSheet("QLabel { border-image: url(:/new/prefix1/1.png); } QLabel{color: rgb(225, 0, 0);}");
    myLabel[index_of_label]->setText(teststring);
    myLabel[index_of_label]->setWordWrap(true);
    myLabel[index_of_label]->setMargin(6);
    ui->verticalLayout->addWidget(myLabel[index_of_label]);

    ui->verticalLayout->setMargin(5);
    ui->scrollAreaWidgetContents->setLayout(ui->verticalLayout);
    ui->scrollArea->setWidget(ui->scrollAreaWidgetContents);
    ui->scrollArea->show();
    }
    Last edited by lipos123; 2011-03-31 at 15:36.

  2. #2
    Regular Contributor e.merhej's Avatar
    Join Date
    Apr 2010
    Posts
    89
    DID you tried one of the following?
    ui->scrollArea->setFocus();
    or
    ui->scrollArea->verticalScrollBar()->setFocus();
    maybe that will solve it
    cheers

  3. #3
    Registered User lipos123's Avatar
    Join Date
    Jan 2011
    Posts
    192
    Quote Originally Posted by e.merhej View Post
    DID you tried one of the following?

    maybe that will solve it
    cheers
    it didn't work,
    note that i have a textbox and a pushbutton under the scroll area...
    any help ?

  4. #4
    Regular Contributor e.merhej's Avatar
    Join Date
    Apr 2010
    Posts
    89
    did u tried to set focus for that pushbutton or text box inside the scroll area?

  5. #5
    Registered User lipos123's Avatar
    Join Date
    Jan 2011
    Posts
    192
    Quote Originally Posted by e.merhej View Post
    did u tried to set focus for that pushbutton or text box inside the scroll area?
    yes, it focus well on the textbox and the pushbutton, but not on the scroll area

  6. #6
    Registered User lipos123's Avatar
    Join Date
    Jan 2011
    Posts
    192
    Any idea ?

  7. #7
    Nokia Developer Expert Fuzzbender's Avatar
    Join Date
    Feb 2008
    Posts
    183
    Try:

    Code:
    ui->scrollArea->setFocusPolicy(Qt::StrongFocus);
    ui->scrollArea->setFocus();
    Though by default QAbstractScrollArea should have Qt::WheelFocus, which is almost the same.

Similar Threads

  1. ScrollArea problem
    By lipos123 in forum [Archived] Beginning Qt
    Replies: 3
    Last Post: 2011-03-04, 22:01
  2. Capture keyevent inside scrollarea
    By novemberox in forum Qt
    Replies: 6
    Last Post: 2010-09-01, 13:10

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved