what's wrong with this

96 views
Skip to first unread message

Al As

unread,
Jul 24, 2022, 1:03:01 PM7/24/22
to The Ring Programming Language

hi all

i have been trying from 3 days to make my program in the center of screen but always showing this error

Capture.PNG

here is my code:

# Form/Window Controller - Source Code File


load "bookslibraryView.ring"


import System.GUI


if IsMainSourceFile() {

   new App {

       StyleFusionblack()

       openWindow(:bookslibraryController)

       exec()

   }

}


class bookslibraryController from windowsControllerParent


   oView = new bookslibraryView

posme()


   func Search

       oView {

           

       }


func posme()

oView {

screenW = wid.screen().width()

screenh = wid.screen().height()

formw = win.width()

formh = win.height()

x = (screenw-formw)/2

y = (screenh-formh)/2

win.move(x,y)

}

private

wid = new qDesktopwidget()


can anyone figure out what is wrong


thanks

Mahmoud Fayed

unread,
Jul 24, 2022, 4:27:38 PM7/24/22
to The Ring Programming Language
Hello Alaa

(1) Use the methods width() and height() that belong to QDesktopWidget
Without using Screen()
You have: wid = new qDesktopwidget()

So You can use

screenW = wid.width()

screenh = wid.height()

(2) When you access an object using braces (like using oView { } )
In this case You changed the current object (The visible attributes/methods are changed!)

So, using oView { } inside the posme Method
Means You can't access the bookslibraryController object attributes like (wid) directly (You need Width)

Solution [1]

Use this

screenW = this.wid.width()

screenh = this.wid.height()

Solution [2]
Don't use This but try moving the next code before oView { }

screenW = wid.width()

screenh = wid.height()

Greetings,
Mahmoud

Ilir

unread,
Jul 24, 2022, 5:22:28 PM7/24/22
to The Ring Programming Language
Hello Mahmoud,

on that note (QDesktopWidget), samples/AQuickStart/GUILib/gui44.ring fails

Line 23 Error (R14) : Calling Method without definition !: primaryscreen

        oRect = oDesktop.screenGeometry( oDesktop.primaryScreen() )

works if function argument changes to

        oRect = oDesktop.screenGeometry( win1 )

Mahmoud Fayed

unread,
Jul 24, 2022, 5:42:25 PM7/24/22
to The Ring Programming Language
Hello Ilir

>> "on that note (QDesktopWidget), samples/AQuickStart/GUILib/gui44.ring fails"

Thanks for the report



Greetings,
Mahmoud

Al As

unread,
Jul 25, 2022, 12:13:16 PM7/25/22
to The Ring Programming Language
hello Mahmoud
i followed your suggestion , the error gone but the window not come to the center of screen

class bookslibraryController from windowsControllerParent

   oView = new bookslibraryView

pCenter


   func Search

       oView {

       }

func pCenter()

screenW = wid.width()

screenh = wid.height()

// //

oView {

formw = win.width()

formh = win.height()

x = (screenw-formw)/2

y = (screenh-formh)/2

win.move(x,y)

}

private

wid = new qDesktopwidget()


please advise.
thanks

Mahmoud Fayed

unread,
Jul 25, 2022, 2:19:23 PM7/25/22
to The Ring Programming Language
Hello Alaa

>> "i followed your suggestion , the error gone but the window not come to the center of screen"

You forge to call the method

Change

oView = new bookslibraryView

pCenter

 
To

oView = new bookslibraryView

pCenter()

i.e. Add () after pCenter to indicate that you are calling a method, not defining an attribute

Greetings,

Mahmoud

Al As

unread,
Jul 26, 2022, 11:59:07 AM7/26/22
to The Ring Programming Language
Thanks ,
i already did it prior to sending my last message , it didn't work either
could you please copy the same code and try it on your computer and se it wont work

thanks

Mahmoud Fayed

unread,
Jul 26, 2022, 8:26:18 PM7/26/22
to The Ring Programming Language
Hello Alaa



The window will starts at the Center
Also, You can move it then click the button to move it to the center again.

Source Code:

class testController from windowsControllerParent


   oDesktop = new QDesktopWidget()

   oView = new testView

   Center_the_Window()


   func Center_the_Window

       

       oView.win {

           move((this.oDesktop.Width()-Width())/2,(this.oDesktop.Height()-Height())/2)
      
       }


Greetings,
Mahmoud

Al As

unread,
Jul 27, 2022, 12:39:06 PM7/27/22
to The Ring Programming Language
Dear Mahmoud ,

sorry for taking your time , i attached my files , i still receive same error

thanks
Books library.rar

Ilir

unread,
Jul 27, 2022, 1:34:55 PM7/27/22
to The Ring Programming Language
Hello,

you are missing    oDesktop  = new qDesktopWidget()

class bookslibraryController from windowsControllerParent
        oDesktop  = new qDesktopWidget()
        oView = new bookslibraryView
           Center_the_Window()

 

    func Center_the_Window
       
        oView.win {
            move((this.oDesktop.Width()-Width())/2,(this.oDesktop.Height()-Height())/2)
        }

    func Search
        oView {
           
        }

Al As

unread,
Jul 29, 2022, 9:41:39 AM7/29/22
to The Ring Programming Language
thanks Ilir ,
centre desktop work now , now i am trying to donload html content of website but also showing me errors
here is the full code

# Form/Window Controller - Source Code File


load "bookslibraryView.ring"



import System.GUI


if IsMainSourceFile() {

   new App {

       StyleFusionblack()

       openWindow(:bookslibraryController)

       exec()

   }

}


class bookslibraryController from windowsControllerParent

oDesktop = new qDesktopWidget()

   oView = new bookslibraryView

Center_the_Window()//لوضع النافذة في وسط الشاشة والتركيز في مربع البحث



   Func Center_the_Window

       oView.win {

    move((this.oDesktop.Width()-Width())/2,(this.oDesktop.Height()-Height())/2)

   }

oView.lineedit1.setfocus(0)//التركيز على مربع البحث

oView.lineedit1.selectall() // تحديد النص في مربع البحث


   

Func pDownload

manager = null

   oUrl = new QUrl("http://ring-lang.sourceforge.net")


   request = new qNetworkRequest(oUrl)

   request.setrawheader(new qbytearray().append("User-Agent"), new qbytearray().append("Application"))


   manager = new qNetworkAccessManager(oView.win)

   {

       setfinishedevent("pfinish()")

   }


   manager.getvalue(request)



Func pfinish

   reply = new qNetworkReply { pObject = manager.getEventParameters()[1] }

   see reply.readall().data()





can someone help

alaa

Ilir

unread,
Jul 29, 2022, 5:03:56 PM7/29/22
to The Ring Programming Language
Hello,

you are missing the Search function right after Center_the_Window as it was previously

    func Search
        oView {
           
        }

Ilir

unread,
Jul 30, 2022, 6:24:30 AM7/30/22
to The Ring Programming Language
Hello,

and you need to move manager = null to global scope, then you can call pDownload within search function or wherever you want inside the bookslibraryController.

Al As

unread,
Jul 31, 2022, 4:22:07 AM7/31/22
to The Ring Programming Language
hello
i did this , the problem the result is empty ,it is not reading the website content

Capture2.PNG

Ilir

unread,
Jul 31, 2022, 5:27:07 AM7/31/22
to The Ring Programming Language
Hello,

   oview.ListWidget1.addItem(reply.readall().data())

Al As

unread,
Aug 1, 2022, 2:22:48 PM8/1/22
to The Ring Programming Language
thanks llir
but also same no result come

regards

Ilir

unread,
Aug 1, 2022, 4:14:39 PM8/1/22
to The Ring Programming Language
Hello,

then you are doing something wrong. Share your code or find solution yourself because it is working for me.

Bert Mariani

unread,
Aug 1, 2022, 6:48:17 PM8/1/22
to The Ring Programming Language
Hello Alaa

Instead of this continuous "what's wrong with this"  postings.
We cannot read your mind as to what you wish to accomplish.
Post your ENTIRE CODE so that we can see what you are doing !!!
And if it has embedded Comments ... it would greatly help.

Last point ... try doing some debugging and testing first.

Al As

unread,
Aug 2, 2022, 12:38:07 PM8/2/22
to The Ring Programming Language
Hello Bert ,
if you had read the above posts ,you would know i have shared the code ,and i said what i am trying to do , i want to write any website address in lineedit then download the html text from it .
thanks
Reply all
Reply to author
Forward
0 new messages